From 368f6130ec26b08fd6fef209514a54a1055dcdbe Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 19 Jun 2020 16:02:27 -0500 Subject: [PATCH] rem config.py, basic scores data, api and basic routes --- config.py | 0 trivia/api.py | 27 ++++++++++++++++++++++++++- trivia/data/scores.json | 16 ++++++++++++++++ trivia/routes.py | 14 +++++++++++++- 4 files changed, 55 insertions(+), 2 deletions(-) delete mode 100644 config.py create mode 100644 trivia/data/scores.json diff --git a/config.py b/config.py deleted file mode 100644 index e69de29..0000000 diff --git a/trivia/api.py b/trivia/api.py index d598da0..bc87bab 100644 --- a/trivia/api.py +++ b/trivia/api.py @@ -2,4 +2,29 @@ api.py Handles backend routes assisting -""" \ No newline at end of file +""" +from flask import request + +from trivia import app + + +@app.route("/api/changed") +@app.route("/api/changed/") +def changed(): + """ + A simple substitute for the 304 Not Modified HTTP return. + + :return True if data has changed since last + + TODO: Remove this function once a proper 304 Not Modified implementation is found for client side. + """ + + time = request.args.get('last') + + +@app.route("/api/refresh") +@app.route("/api/refresh/") +def refresh(): + """ + Used for refreshing client-side table data. Returns a JSON response with all data necessary to build the table. + """ diff --git a/trivia/data/scores.json b/trivia/data/scores.json new file mode 100644 index 0000000..a01d0b4 --- /dev/null +++ b/trivia/data/scores.json @@ -0,0 +1,16 @@ +[ + { + "teamno" : 0, + "teamname" : "Example Team 1", + "scores" : [ + 1, 2, 3, 4 + ] + }, + { + "teamno" : 1, + "teamname" : "Example Team 2", + "scores" : [ + 5, 6, 7, 8 + ] + } +] \ No newline at end of file diff --git a/trivia/routes.py b/trivia/routes.py index 397eb4f..621acef 100644 --- a/trivia/routes.py +++ b/trivia/routes.py @@ -2,4 +2,16 @@ routes.py Handles user frontend routes. -""" \ No newline at end of file +""" + +from trivia import app + + +@app.route("/") +def index(): + """ + Handles the frontend user index. + + :return: + """ + return 'index'