Check if file is present in `parse_file` method
Closed this issue · 1 comments
parse_file
method gives an error if there is no file present.
Line 23 in a1c9270
Task
Add a check to ensure file is present in the request. If not send out the following error message
"Please upload a file to proceed."
I guess you refer to a empty request.file, right?
a good sample looks like this: ImmutableMultiDict([('0', <FileStorage: 'whatsapp_chat_en.txt' ('text/plain')>)])
, in case you refer to empty, my best idea is:
in app.py (line 22)
file_req = request.files
if len(file_req) == 0:
response = {
"success": False,
"error_message": "Please upload a file to proceed.",
}
return jsonify(response), 200
file = file_req['0']
I was not able to re-create it so I set the dict to 0 and tested the flow. It worked as expected. But maybe you refer to a different case, otherwise I will add this. If this does not meet your original issue, please add some info on how to re-create this issue.