i work on a little flask app, which consists in searching docs with keywords (ElasticSSearch) and upload docs in cluster.
Searching docs works fine but upload is hard, i can do it with curl but i have some problems
My curl command is like:
curl -F "file=@pdf-test.pdf" "http://127.0.0.1:pdf-8080/fscrawler/_upload"
My html is:
<form id="uploadbanner" enctype="multipart/form-data" method="post" action="/">
<input id="fileupload" name="myfile" type="file" />
<input type="submit" value="submit" id="submit" />
</form>
in order to create upload button for the client.
I saw many topic about requests library, but my py code does not work, i really do not understand what i do wrong, and i am pretty lost.
I give you what i tried:
def upload():
url="http://127.0.0.1:8080/fscrawler/_upload"
if request.method == 'POST':
payload = open("test.pdf")
r = requests.post(url, data=payload)
Thanks for help, and have a good day :)