I have a python script that need to upload a file using http.client and payload packages. I tried to upload a text file using the parameters of request.post but the system crash and display the below error:
Exception has occurred: TypeError
request() got an unexpected keyword argument 'files'
I tried to pass a files parameter as a tuple as the document said.
code:
import http.client
from IPython.core import payload
files = {'document': open("F:/AIenv/textAnalysis/testin2.txt","r",encoding = "utf-8")}
conn = http.client.HTTPSConnection("farasa-api.qcri.org")
headers = { "content-type": "application/json", "cache-control": "no-cache", }
conn.request("POST", "/msa/webapi/lemma", files = files, headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))