I'm uploading a file to my flask backend and I can't figure out how to access the parameter values in the multipart form.
I can access the uploaded file easily by doing
file = request.files['file']
Most form inputs can be retrieved as follows:
Files can be accessed via
Where the fieldnames are the
name attribute in the HTML.
Keep in mind that, just because there's a result for
request.files.get("someName") doesn't mean a file was actually uploaded. You should check that the filename exists, too, in order to validate if a file was indeed uploaded.
Take for example, the following HTML
<form action="/form_endpoint" method="POST"> <input type="text" name="data"> <input type="submit" value="submit"> </form>
You would access the value the user input in the
data field by
data = request.form.get("data")