-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (43 loc) · 1.4 KB
/
main.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
import logging
import flask
import settings
from api import basehandlers
from api import arena_api
from api import cmd_api
from api import players_api
from api import story_api
api_routes = [
('/story', story_api.StoryAPI),
('/players/<int:arena_id>', players_api.PlayersAPI),
('/players/<int:arena_id>/<string:player_id>',
players_api.PlayersAPI),
('/cmds/<int:arena_id>/<int:player_id>', cmd_api.CommandAPI),
('/arenas', arena_api.ArenaAPI),
('/arenas/<int:arena_id>/<int:player_id>', arena_api.ArenaAPI),
]
app = basehandlers.FlaskApplication(
__name__, api_routes, '/api/v0')
page_views = 0
@app.route("/hello")
def hello_world():
global page_views
page_views += 1
return "<p>Hello, World!</p> page_views is %d" % page_views
@app.route('/node_modules/<path:filename>')
def node_modules(filename):
logging.info('request for node_modules %r' % filename)
return flask.send_from_directory(
app.root_path + '/node_modules/', filename)
@app.route('/', defaults={'path': ''})
def home_page(path):
logging.info('serving home page: %r', path)
return flask.render_template(
'index.html',
version=settings.APP_VERSION)
@app.route("/<string:path>")
@app.route('/<path:path>')
def spa_pages(path):
logging.info('serving spa page: %r', path)
return flask.render_template(
'game.html',
version=settings.APP_VERSION)