Adding the ability to view entries one by one

This commit is contained in:
Denis-Cosmin Nutiu 2017-04-13 21:00:36 +03:00
parent 4cd66dd1de
commit 16d7b37cb2
3 changed files with 35 additions and 13 deletions

23
src/templates/entry.html Normal file
View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="author" content="Metonymy">
<meta name="description" content="The scoreboard for the benchmarks!">
<meta name="keywords" content="flask python metonymyqt benchmark scoreboard">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css')}}">
<title>Scoreboard!</title>
</head>
<body>
<header>
<h1>The Scoreboard!</h1>
</header>
<main>
<h1>{{ name.text }}</h1>
<h1>{{ name.score }}</h1>
</main>
<footer>
Copyright 2017 Fellowship of the Bits
</footer>
</body>
</html>

View file

@ -17,11 +17,13 @@
<tr>
<th>Text</th>
<th>Score</th>
<th>Information</th>
</tr>
{% for item in results %}
<tr>
<td>Text: {{ item.text }} </td>
<td>Score: {{ item.score }}</td>
<td>{{ item.text }}</td>
<td>{{ item.score }}</td>
<td><a href="{{ url_for('scoreboard.entry', id=item.id) }}">See more</a></td>
</tr>
{% endfor %}
</table>

View file

@ -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/<id>")
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)