-
Notifications
You must be signed in to change notification settings - Fork 31
/
app.py
32 lines (25 loc) · 966 Bytes
/
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
from flask import redirect, jsonify, request
from sqlalchemy_utils import database_exists
from config import APP_CONFIG, API_PREFIX, DB_NAME
from api import create_app
from db.populate_tables import populate_db
from db import db
from collections import OrderedDict
app = create_app(APP_CONFIG)
with app.app_context():
if not database_exists(DB_NAME):
db.create_all()
populate_db()
@app.route("/" + API_PREFIX)
def show_resources():
resources = [('civilizations', '{}/civilizations'.format(request.url)),
('units', '{}/units'.format(request.url)),
('structures', '{}/structures'.format(request.url)),
('technologies', '{}/technologies'.format(request.url))
]
return jsonify({'resources': OrderedDict(resources)})
@app.route("/")
def redirect_to_docs():
return redirect("docs/", code=302)
if __name__ == "__main__":
app.run(port=5000, debug=True, host='0.0.0.0')