From 628b82fcfd01f444cd8bece74911ffdd16c06270 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 6 Nov 2018 23:18:02 +0100 Subject: [PATCH] Add flask page --- templates/minis/discord.html | 2 +- webserver.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/templates/minis/discord.html b/templates/minis/discord.html index 655d3277..23f073b9 100644 --- a/templates/minis/discord.html +++ b/templates/minis/discord.html @@ -25,7 +25,7 @@ {% if record["fav_song"] %}
Canzone preferita
- {{ record["fav_song"] }} + {{ record["fav_song"] }}
{{ record["max_plays"] }}x
{% else %} diff --git a/webserver.py b/webserver.py index 1cf43e45..fee1b6fa 100644 --- a/webserver.py +++ b/webserver.py @@ -342,20 +342,15 @@ def page_music(): return render_template("topsongs.html", songs=songs) -@app.route("/music/") -def page_music_individual(name: str): +@app.route("/music/") +def page_music_individual(discord_id: str): db_session = db.Session() - user = db_session.query(db.Royal).filter_by(username=name).one_or_none() - if user is None: - db_session.close() - abort(404) - return - discord = db_session.query(db.Discord).filter_by(royal=user).one_or_none() + discord = db_session.query(db.Discord).filter_by(discord_id=discord_id).one_or_none() if discord is None: db_session.close() abort(404) return - songs = db_session.execute(query_discord_music.single_top_songs, {"discordid": discord.id}) + songs = db_session.execute(query_discord_music.single_top_songs, {"discordid": discord.discord_id}) db_session.close() return render_template("topsongs.html", songs=songs, discord=discord)