-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapplication.wsgi
More file actions
72 lines (56 loc) · 2.1 KB
/
application.wsgi
File metadata and controls
72 lines (56 loc) · 2.1 KB
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
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# vim:fileencoding=utf-8:ts=8:et:sw=4:sts=4:tw=79
"""
application.wsgi
The "Pump19 Twitch Chat Golem" bottle application.
Copyright (c) 2020 Kevin Perry <perry at pump19 dot eu>
See the file LICENSE for copying permission.
"""
from beaker.middleware import SessionMiddleware
from bottle import Bottle
from bottle.ext import sqlalchemy
from functools import partial
from os import environ
from sqlalchemy import create_engine
import routes
app = Bottle()
# install plugins
engine = create_engine(environ["DATABASE_URL"])
sa_plugin = sqlalchemy.Plugin(engine, commit=False)
app.install(sa_plugin)
session_opts = {
"session.type": "file",
"session.data_dir": environ["SESSION_DATA_DIR"],
"session.url": environ["DATABASE_URL"],
"session.cookie_domain": environ["SESSION_COOKIE_DOMAIN"],
"session.cookie_expires": False,
"session.secret": environ["SESSION_SECRET"]
}
application = SessionMiddleware(app, session_opts)
# misc routes
app.route("/", "GET", routes.misc.home)
app.route("/commands", "GET", routes.misc.commands)
app.route("/contribute", "GET", routes.misc.contribute)
# bingo routes
app.route("/bingo", "GET", routes.bingo.main)
app.route("/bingo/<show>", "GET", routes.bingo.show)
# codefall routes
app.route("/codefall", "GET", routes.codefall.main)
app.route("/codefall/<secret:re:[a-z]{6}>", "GET", routes.codefall.show)
app.route("/codefall/add", "POST", routes.codefall.add)
app.route("/codefall/announce", "POST", routes.codefall.announce)
app.route("/codefall/claim/<secret:re:[a-z]{6}>", "POST", routes.codefall.claim)
# auth routes
app.route("/login", "GET", routes.auth.login)
app.route("/logout", "GET", routes.auth.logout)
app.route("/oauth", "GET", routes.auth.oauth)
if __name__ == "__main__":
# we start a local dev server when this file is executed as a script
# add a route for static files
from bottle import static_file, run
@app.route("/static/<filepath:path>")
def serve_static(filepath):
return static_file(filepath, "./dist")
run(app=application,
host="pump19.localhost", port=8080,
reloader=True, debug=True)