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
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
15 app.config.from_envvar('WRADMIN_SETTINGS')
16 db_engine = create_engine(app.config['DATABASE_URI'])
17 wradmin.model.init_model(db_engine)
21 """Opens a new database connection if there is none yet for the current application context."""
22 if not hasattr(g, 'db'):
23 g.db = db_engine.connect()
27 @app.teardown_appcontext
29 """Closes the database connection at the end of the request."""
36 return render_genshi_template('index.html')
39 @app.route("/rodelbahn/list")
42 return RodelbahnController().list()
45 @app.route("/rodelbahn/view/<int:id>")
46 def rodelbahn_view(id):
48 return RodelbahnController().view(id)
51 @app.route("/rodelbahn/update")
52 def rodelbahn_update():
54 return RodelbahnController().update()
57 @app.route("/rodelbahn/update_regioncache")
58 def rodelbahn_update_regioncache():
60 return RodelbahnController().update_regioncache()
63 @app.route("/bericht/list")
66 return BerichtController().list()
69 @app.route("/bericht/view/<int:id>")
72 return BerichtController().view(id)
75 @app.route("/bericht/change_date_invalid/<int:id>", methods=['POST'])
76 def bericht_change_date_invalid(id):
78 return BerichtController().change_date_invalid(id)
81 @app.route("/gasthaus/list")
84 return GasthausController().list()
87 @app.route("/gasthaus/view/<int:id>")
88 def gasthaus_view(id):
90 return GasthausController().view(id)
93 @app.route("/gasthaus/update")
94 def gasthaus_update():
96 return GasthausController().update()
99 @app.route("/coordtool/index")
100 def coordtool_index():
101 return CoordtoolController().index()
104 @app.route("/coordtool/convert", methods=['POST'])
105 def coordtool_convert():
106 return CoordtoolController().convert()