]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/__init__.py
Remove explicit get_db and now calling Session.remove() at the end of requests.
[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 import wradmin.model
7 from wradmin.genshi import render_genshi_template
8 from wradmin.controllers.rodelbahn import RodelbahnController
9 from wradmin.controllers.gasthaus import GasthausController
10 from wradmin.controllers.bericht import BerichtController
11 from wradmin.controllers.coordtool import CoordtoolController
12
13
14 app = Flask(__name__)
15 app.config.from_envvar('WRADMIN_SETTINGS')
16 wradmin.model.init_model(create_engine(app.config['DATABASE_URI']))
17
18
19 @app.teardown_appcontext
20 def remove_db_session(error):
21     """Removes the database session at the end of the request."""
22     wradmin.model.meta.Session.remove()
23
24
25 @app.route("/")
26 def index():
27     return render_genshi_template('index.html')
28
29
30 @app.route("/rodelbahn/list")
31 def rodelbahn_list():
32     return RodelbahnController().list()
33
34
35 @app.route("/rodelbahn/view/<int:id>")
36 def rodelbahn_view(id):
37     return RodelbahnController().view(id)
38
39
40 @app.route("/rodelbahn/update")
41 def rodelbahn_update():
42     return RodelbahnController().update()
43
44
45 @app.route("/rodelbahn/update_regioncache")
46 def rodelbahn_update_regioncache():
47     return RodelbahnController().update_regioncache()
48
49
50 @app.route("/bericht/list")
51 def bericht_list():
52     return BerichtController().list()
53
54
55 @app.route("/bericht/view/<int:id>")
56 def bericht_view(id):
57     return BerichtController().view(id)
58
59
60 @app.route("/bericht/change_date_invalid/<int:id>", methods=['POST'])
61 def bericht_change_date_invalid(id):
62     return BerichtController().change_date_invalid(id)
63
64
65 @app.route("/gasthaus/list")
66 def gasthaus_list():
67     return GasthausController().list()
68
69
70 @app.route("/gasthaus/view/<int:id>")
71 def gasthaus_view(id):
72     return GasthausController().view(id)
73
74
75 @app.route("/gasthaus/update")
76 def gasthaus_update():
77     return GasthausController().update()
78
79
80 @app.route("/coordtool/index")
81 def coordtool_index():
82     return CoordtoolController().index()
83
84
85 @app.route("/coordtool/convert", methods=['POST'])
86 def coordtool_convert():
87     return CoordtoolController().convert()