From 7c1f449bcebbf19b1b1051372140c0c965e92c45 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sat, 5 Sep 2020 18:55:56 -0500 Subject: [PATCH] Add "verify" field to request to not save image This makes it easy for the user to debug authentication. --- imgupload.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imgupload.py b/imgupload.py index 6512a4b..05b729c 100644 --- a/imgupload.py +++ b/imgupload.py @@ -49,6 +49,11 @@ def upload(): if request.form["uploadKey"] in validkeys: # check if uploadKey is valid print("Key is valid!") + if "verify" in request.form.keys(): + if request.form["verify"] == "true": + print("Request is asking if key is valid (it is)") + return jsonify({'status': 'key_valid'}) + if "imageUpload" in request.files: # check if image to upload was provided f = request.files["imageUpload"] # f is the image to upload else: @@ -92,10 +97,5 @@ def upload(): print("No uploadKey found in request!") return jsonify({'status': 'error', 'error': 'UNAUTHORIZED'}), status.HTTP_401_UNAUTHORIZED - - else: # if the request method wasn't post - print("Request method was not POST!") - return jsonify({'status': 'error', 'error': 'METHOD_NOT_ALLOWED'}), status.HTTP_405_METHOD_NOT_ALLOWED - if __name__ == "__main__": print("Run with `flask` or a WSGI server!")