mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
from flask import Flask, render_template
|
|
from db import Session, Royal, Steam, RocketLeague, Dota, Osu, Overwatch, LeagueOfLegends, Diario, Telegram, PlayedMusic, Discord
|
|
from sqlalchemy import func
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.jinja_env.trim_blocks = True
|
|
app.jinja_env.lstrip_blocks = True
|
|
|
|
|
|
@app.route("/")
|
|
def page_index():
|
|
return render_template("index.html")
|
|
|
|
|
|
@app.route("/diario")
|
|
def page_diario():
|
|
session = Session()
|
|
diario_data = session.query(Diario).outerjoin((Telegram, Diario.author), aliased=True).outerjoin(Royal, aliased=True).outerjoin((Telegram, Diario.saver), aliased=True).outerjoin(Royal, aliased=True).all()
|
|
session.close()
|
|
return render_template("diario.html", diario_data=diario_data)
|
|
|
|
|
|
@app.route("/leaderboards")
|
|
def page_leaderboards():
|
|
session = Session()
|
|
dota_data = session.query(Dota).join(Steam).join(Royal).order_by(Dota.rank_tier).all()
|
|
rl_data = session.query(RocketLeague).join(Steam).join(Royal).order_by(RocketLeague.doubles_mmr).all()
|
|
ow_data = session.query(Overwatch).join(Royal).order_by(Overwatch.rank).all()
|
|
osu_data = session.query(Osu).join(Royal).order_by(Osu.std_pp).all()
|
|
lol_data = session.query(LeagueOfLegends).join(Royal).order_by(LeagueOfLegends.summoner_name).all()
|
|
session.close()
|
|
return render_template("leaderboards.html", dota_data=dota_data, rl_data=rl_data, ow_data=ow_data, osu_data=osu_data, lol_data=lol_data)
|
|
|
|
|
|
@app.route("/music")
|
|
def page_music():
|
|
session = Session()
|
|
music_counts = session.query(PlayedMusic.filename, func.count(PlayedMusic.filename)).group_by(PlayedMusic.filename).all()
|
|
music_last = session.query(PlayedMusic).join(Discord).join(Royal).order_by(PlayedMusic.id.desc()).limit(50).all()
|
|
session.close()
|
|
return render_template("music.html", music_counts=music_counts, music_last=music_last)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
app.run(host="0.0.0.0", port=1234)
|
|
except KeyboardInterrupt:
|
|
pass
|