From 41218817fbc3ee15a2c5bfd8dd2d7a69ed05910a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nut=CC=A6iu?= Date: Sun, 16 Apr 2017 21:16:47 +0300 Subject: [PATCH] Adding a get method for /upload --- src/views/scoreboard.py | 5 ++++- test/test_scoreboard.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/views/scoreboard.py b/src/views/scoreboard.py index a687f96..9e6f622 100644 --- a/src/views/scoreboard.py +++ b/src/views/scoreboard.py @@ -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: diff --git a/test/test_scoreboard.py b/test/test_scoreboard.py index 931f2a7..85d0bb3 100644 --- a/test/test_scoreboard.py +++ b/test/test_scoreboard.py @@ -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)