]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/__init__.py
8fa96e25e3c6f460f9c2a62f873bd3fe929b63cc
[philipp/winterrodeln/wradmin.git] / wradmin / __init__.py
1 # http://flask.pocoo.org/
2 # FLASK_APP=wradmin FLASK_DEBUG=1 WRADMIN_SETTINGS=development.cfg python3 -m flask run
3 # FLASK_APP=wradmin WRADMIN_SETTINGS=production.cfg python3 -m flask run
4 from flask import Flask, send_from_directory, abort, g
5 from sqlalchemy.engine import create_engine
6
7
8 app = Flask(__name__)
9 app.config.from_envvar('WRADMIN_SETTINGS')
10
11
12 def get_db():
13     """Opens a new database connection if there is none yet for the
14     current application context.
15     """
16     if not hasattr(g, 'db'):
17         g.db_engine = create_engine(app.config['DATABASE_URI'])
18         g.db = g.db_engine.connect()
19     return g.db
20
21
22 @app.teardown_appcontext
23 def close_db(error):
24     """Closes the database again at the end of the request."""
25     if hasattr(g, 'db'):
26         g.db.close()
27
28
29 @app.route("/")
30 def hello():
31     return send_from_directory('templates', 'index.html')
32
33
34 @app.route("/rodelbahn/")
35 def rodelbahn_list():
36     pass
37
38
39 @app.route("/bericht/")
40 def bericht_list():
41     pass