]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/__init__.py
URLs from index page work now.
[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 from wradmin.genshi import render_genshi_template
7
8
9 app = Flask(__name__)
10 app.config.from_envvar('WRADMIN_SETTINGS')
11
12
13 def get_db():
14     """Opens a new database connection if there is none yet for the
15     current application context.
16     """
17     if not hasattr(g, 'db'):
18         g.db_engine = create_engine(app.config['DATABASE_URI'])
19         g.db = g.db_engine.connect()
20     return g.db
21
22
23 @app.teardown_appcontext
24 def close_db(error):
25     """Closes the database again at the end of the request."""
26     if hasattr(g, 'db'):
27         g.db.close()
28
29
30 @app.route("/")
31 def index():
32     return render_genshi_template('index.html')
33
34
35 @app.route("/rodelbahn/list")
36 def rodelbahn_list():
37     pass
38
39
40 @app.route("/bericht/list")
41 def bericht_list():
42     pass
43
44
45 @app.route("/gasthaus/list")
46 def gasthaus_list():
47     pass
48
49
50 @app.route("/coordtool/index")
51 def coordtool_index():
52     pass