From 8a7e6d34fd166bbb769fb9b657727e1702174e44 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 13 Oct 2017 09:39:27 +0200 Subject: [PATCH] website stuff --- flaskserver.py | 32 ++++++++----------- templates/main.htm | 51 ++++++++++++++++++++++++++++++ templates/rl_table.htm | 70 ++++++++++++++++++++++++++++++++++++++++++ templates/table.htm | 54 +++++++++++++------------------- 4 files changed, 155 insertions(+), 52 deletions(-) create mode 100644 templates/main.htm create mode 100644 templates/rl_table.htm diff --git a/flaskserver.py b/flaskserver.py index b389a89a..3ed520b7 100644 --- a/flaskserver.py +++ b/flaskserver.py @@ -3,27 +3,21 @@ from flask import Flask, render_template app = Flask(__name__) -@app.route("/dota/ladder") +@app.route("/ladder") def page_dota_ladder(): session = db.Session() - query = session.execute("SELECT royals.username, dota.solo_mmr, dota.party_mmr, dota.wins FROM royals JOIN steam ON royals.id = steam.royal_id JOIN dota ON steam.steam_id = dota.steam_id ORDER BY dota.solo_mmr DESC;") - return render_template("table.htm", query=query) - - -@app.route("/rl/ladder") -def page_rl_ladder(): - session = db.Session() - query = session.execute("SELECT royals.username, rocketleague.single_mmr, rocketleague.doubles_mmr, rocketleague.standard_mmr, rocketleague.solo_std_mmr FROM royals JOIN steam ON royals.id = steam.royal_id JOIN rocketleague ON steam.steam_id = rocketleague.steam_id ORDER BY rocketleague.doubles_mmr DESC;") - return render_template("table.htm", query=query) - - -@app.route("/osu/ladder") -def page_osu_ladder(): - session = db.Session() - query = session.execute("SELECT royals.username, osu.std_pp, osu.taiko_pp, osu.catch_pp, osu.mania_pp FROM royals JOIN osu ON royals.id = osu.royal_id ORDER BY osu.std_pp DESC;") - return render_template("table.htm", query=query) - + dota = session.execute("SELECT royals.username, dota.solo_mmr, dota.party_mmr, dota.wins FROM royals JOIN steam ON royals.id = steam.royal_id JOIN dota ON steam.steam_id = dota.steam_id ORDER BY dota.solo_mmr DESC;") + rl = session.execute("SELECT royals.username, " + "rocketleague.single_rank, rocketleague.single_div, rocketleague.single_mmr, " + "rocketleague.doubles_rank, rocketleague.doubles_div, rocketleague.doubles_mmr, " + "rocketleague.standard_rank, rocketleague.standard_div, rocketleague.standard_mmr, " + "rocketleague.solo_std_rank, rocketleague.solo_std_div, rocketleague.solo_std_mmr " + "FROM royals JOIN steam ON royals.id = steam.royal_id " + "JOIN rocketleague ON steam.steam_id = rocketleague.steam_id " + "ORDER BY rocketleague.doubles_rank DESC;") + osu = session.execute("SELECT royals.username, osu.std_pp, osu.taiko_pp, osu.catch_pp, osu.mania_pp FROM royals JOIN osu ON royals.id = osu.royal_id ORDER BY osu.std_pp DESC;") + return render_template("main.htm", dota=dota, rl=rl, osu=osu) if __name__ == "__main__": - app.run() \ No newline at end of file + app.run(host="0.0.0.0", port=1234) \ No newline at end of file diff --git a/templates/main.htm b/templates/main.htm new file mode 100644 index 00000000..75d73d7d --- /dev/null +++ b/templates/main.htm @@ -0,0 +1,51 @@ + + + + + + Ladders + + + + +
+

+ Dota 2 +

+ {% with query=dota %} + {% include 'table.htm' %} + {% endwith %} +

+ Rocket League +

+ {% with query=rl %} + {% include 'rl_table.htm' %} + {% endwith %} +

+ Osu! +

+ {% with query=osu %} + {% include 'table.htm' %} + {% endwith %} +
+ + \ No newline at end of file diff --git a/templates/rl_table.htm b/templates/rl_table.htm new file mode 100644 index 00000000..a7482ef0 --- /dev/null +++ b/templates/rl_table.htm @@ -0,0 +1,70 @@ + + + + + + + + + + + + {% for record in query %} + + + + + + + + {% endfor %} + +
+ Username + + Singolo 1v1 + + Doppio 2v2 + + Standard 3v3 + + Solo Standard Solo 3v3 +
+ {{ record[0] }} + + {% if record[1] %} + + + {{ record[3] }} + + {% else %} + + {% endif %} + + {% if record[4] %} + + + {{ record[6] }} + + {% else %} + + {% endif %} + + {% if record[7] %} + + + {{ record[9] }} + + {% else %} + + {% endif %} + + {% if record[10] %} + + + {{ record[12] }} + + {% else %} + + {% endif %} +
\ No newline at end of file diff --git a/templates/table.htm b/templates/table.htm index 5b6cf244..781ac858 100644 --- a/templates/table.htm +++ b/templates/table.htm @@ -1,36 +1,24 @@ - - - - - - Ladder - - - - - +
+ + + {% for column in query.keys() %} + + {% endfor %} + + + + {% for record in query %} - {% for column in query.keys() %} - + {% for column in record %} + {% endfor %} - - - {% for record in query %} - - {% for column in record %} - - {% endfor %} - - {% endfor %} - -
+ {{ column }} +
- {{ column }} - + {% if column %} + {{ column }} + {% endif %} +
- {% if column %} - {{ column }} - {% endif %} -
- - \ No newline at end of file + {% endfor %} + + \ No newline at end of file