aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/general.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-02-16 23:58:22 +0300
committerBonfaceKilz2021-02-16 23:58:22 +0300
commitcef84aa5509ffc9b0f744c88586a734cec62d446 (patch)
treea9c12cd6b9cb031b433f1b585172929e51a481be /gn3/api/general.py
parent44666e0594a56d2b7911351469555c2f67abaff6 (diff)
downloadgenenetwork3-cef84aa5509ffc9b0f744c88586a734cec62d446.tar.gz
Return the correct message and status code in "/metadata/upload"
Diffstat (limited to 'gn3/api/general.py')
-rw-r--r--gn3/api/general.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/gn3/api/general.py b/gn3/api/general.py
index d52d033..c1b6aa7 100644
--- a/gn3/api/general.py
+++ b/gn3/api/general.py
@@ -11,12 +11,20 @@ from gn3.file_utils import extract_uploaded_file
general = Blueprint("general", __name__)
-@general.route("/metadata/upload")
+@general.route("/metadata/upload", methods=["POST"])
def upload_metadata():
"""Extract uploaded file to gn3 temporary directory; and if successful return
a TOKEN to the user
"""
- results = extract_uploaded_file(gzipped_file=request.files["file"],
- target_dir=current_app.get("TMPDIR"))
- return jsonify(results)
+ file_ = request.files.get("file")
+ if not file_:
+ return jsonify(status=128, error="Please provide a file!"), 400
+
+ status = 201
+ results = extract_uploaded_file(
+ gzipped_file=request.files["file"],
+ target_dir=current_app.config["APP_DEFAULTS"].get("TMPDIR"))
+ if results.get("status") > 0:
+ status = 500
+ return jsonify(results), status