I want to make a multiple file-upload form.I use jQuery File Uploader. My server-side code:
@app.route(\"/new/photogallery\",methods=[\"POST\"])
def newPhotoGall
Regardless of the the data encoding, you should be able to get the raw data with request.data
.
In the case of application/octet-stream
, you can just write request.data
to a binary file.
An example handler for various data types:
from flask import json
@app.route('/messages', methods = ['POST'])
def api_message():
if request.headers['Content-Type'] == 'text/plain':
return "Text Message: " + request.data
elif request.headers['Content-Type'] == 'application/json':
return "JSON Message: " + json.dumps(request.json)
elif request.headers['Content-Type'] == 'application/octet-stream':
with open('/tmp/binary', 'wb') as f:
f.write(request.data)
f.close()
return "Binary message written!"
else:
return "415 Unsupported Media Type ;)"
The typical scenario of handling form data is already documented here.