Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Commit

Permalink
Test for mobile app api call
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Wang committed May 6, 2017
1 parent 4571524 commit 83d5132
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions restapi/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def getMedia(filename):
def uploadMedia():
"""Upload media to the host or return error on fail."""
# Test API key.
print()
apikey = request.form['apikey']
if not api.checkApiKey(apikey):
return jsonify(response.notOkay(403, "Access denied. Incorrect API key."))
return jsonify(response.notOkay(403, "Access denied."))

# Get form params.
mediaType = request.form['type']
Expand All @@ -90,7 +91,7 @@ def uploadMedia():

# Filename must be nonempty to be valid.
if media.filename == '':
return jsonify(response.notOkay(403, "Cannot upload without a filename."))
return jsonify(response.notOkay(403, "No filename."))

# If there aren't any problems getting the file (empty file).
if media:
Expand Down Expand Up @@ -118,7 +119,7 @@ def uploadMedia():
"data": []
})

return jsonify(response.notOkay(400, "No file has been uploaded"))
return jsonify(response.notOkay(401, "No file has been uploaded"))


@app.route('/api/getRelevant', methods=["POST"])
Expand All @@ -127,7 +128,7 @@ def getRelevant():
# Test API key.
apikey = request.form['apikey']
if not api.checkApiKey(apikey):
return jsonify(response.notOkay(403, "Access denied. Incorrect API key."))
return jsonify(response.notOkay(403, "Access denied."))

# Get form params.
try:
Expand Down

0 comments on commit 83d5132

Please sign in to comment.