Adding a get method for /upload

This commit is contained in:
Denis-Cosmin Nutiu 2017-04-16 21:16:47 +03:00
parent bab32e271f
commit 41218817fb
2 changed files with 8 additions and 1 deletions

View file

@ -23,7 +23,7 @@ import flask
scoreboard = flask.Blueprint('scoreboard', __name__, template_folder='templates')
@scoreboard.route("/upload", methods=['POST'])
@scoreboard.route("/upload", methods=['POST', 'GET'])
def upload():
"""
This is the upload view. It accepts JSON only.
@ -33,6 +33,9 @@ def upload():
status code, success true if the data was received successfully and false otherwise and
an error string.
"""
if flask.request.method == 'GET':
flask.abort(404)
content = flask.request.get_json()
try:

View file

@ -63,3 +63,7 @@ class ScoreboardTestCase(unittest.TestCase):
self.assertTrue("true" in response.get_data(as_text=True))
self.assertEqual(response.status_code, 200)
def test_get_upload(self):
response = self.client.get('/upload')
self.assertEqual(response.status_code, 404)