-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
61 lines (41 loc) · 1.25 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import asyncio
from quart import Quart, render_template, request, session, redirect
from auth import auth_required, verify_auth
from blueprints import register_blueprints
from config import SECRET_KEY
from db import User, games, teams, users
app = Quart(__name__)
app.secret_key = SECRET_KEY
register_blueprints(app)
@app.before_serving
async def on_startup():
await games.cache_all()
@app.before_request
async def make_session_permanent():
session.permanent = True
@app.route("/")
async def index():
await games.cache_all()
await users.cache_all()
await teams.cache_all()
return await render_template("index.html")
@app.route("/rules")
async def rules():
return await render_template("rules.html")
@app.route("/profile")
@auth_required(True)
async def profile(user: User):
return await render_template(
"profile.html",
data={
"name": user.name,
},
)
@app.route("/login")
async def login_page():
if (await verify_auth(request))[0]:
return redirect(request.args.get("redirect_uri", "/profile"))
return await render_template("login.html", **dict(request.args))
if __name__ == "__main__":
loop = asyncio.get_event_loop()
app.run(host="0.0.0.0", debug=True, loop=loop)