I am using flash micro framework 0.6 and Python 2.6
I need to get mimetype from the downloaded file so that I can save it.
Here is the corresponding Python / Flask code:
@app.route('/upload_file', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': file = request.files['file'] mimetype =
And here is the code for the webpage:
<form action="upload_file" method=post enctype=multipart/form-data> Select file to upload: <input type=file name=file> <input type=submit value=Upload> </form>
The code works, but I need to be able to get the mimetype when it loads. I looked at the Flask docs here: http://flask.pocoo.org/docs/api/#incoming-request-data
Therefore, I know that it gets the mimetype type, but I cannot figure out how to get it - like a text string, for example. 'Txt / plain.
Any ideas?
Thanks.
python flask webforms
Jon cox
source share