0

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 "[email protected]" "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 :)

0

1 Answer 1

0

Try:

curl -F "[email protected]" "http://127.0.0.1:pdf-8080/fscrawler/_upload"

The name of your file input needs to be the same in curl and html.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes i forget it ! But it does not change anything, i think the problem is in html. There is some things i do not understand well: For example, when i choose a file with upload button, where is my file ? For searching, i had no problems because there is no "object" to manipulate, i just put the content of search in variable then i query my es cluster. But now there is a file and I do not even understand what i do sometimes..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.