diff --git a/src/templates/entry.html b/src/templates/entry.html new file mode 100644 index 0000000..71cdca9 --- /dev/null +++ b/src/templates/entry.html @@ -0,0 +1,23 @@ + + + + + + + + + Scoreboard! + + +
+

The Scoreboard!

+
+
+

{{ name.text }}

+

{{ name.score }}

+
+ + + \ No newline at end of file diff --git a/src/templates/index.html b/src/templates/index.html index eb3f614..bc9d1b0 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -17,11 +17,13 @@ Text Score + Information {% for item in results %} - Text: {{ item.text }} - Score: {{ item.score }} + {{ item.text }} + {{ item.score }} + See more {% endfor %} diff --git a/src/views/scoreboard.py b/src/views/scoreboard.py index d34f27a..86f1c98 100644 --- a/src/views/scoreboard.py +++ b/src/views/scoreboard.py @@ -22,16 +22,6 @@ import flask scoreboard = flask.Blueprint('scoreboard', __name__, template_folder='templates') -# @scoreboard.before_first_request -# def create_test_databases(): -# db.drop_all() -# db.create_all() -# b1 = Result(text="asda", score=100) -# b2 = Result(text="i7 flips flops", score=400) -# db.session.add(b1) -# db.session.add(b2) -# db.session.commit() - @scoreboard.route("/upload", methods=['POST']) def upload(): @@ -50,8 +40,15 @@ def upload(): return json.dumps({'success': True}), 200, {'ContentType': 'application/json'} +@scoreboard.route("/entry/") +def entry(id): + entry_name = Result.query.filter_by(id=id).first() + if entry_name: + return flask.render_template("entry.html", name=entry_name) + + flask.abort(404) @scoreboard.route("/") def index(): - results = Result.query.all() + results = Result.query.order_by(Result.score.desc()).all() return flask.render_template("index.html", results=results)