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')
19 """Opens a new database connection if there is none yet for the
20 current application context.
22 if not hasattr(g, 'db'):
23 g.db_engine = create_engine(app.config['DATABASE_URI'])
24 wradmin.model.init_model(g.db_engine)
25 g.db = g.db_engine.connect()
29 @app.teardown_appcontext
31 """Closes the database again at the end of the request."""
38 return render_genshi_template('index.html')
41 @app.route("/rodelbahn/list")
44 return RodelbahnController().list()
47 @app.route("/rodelbahn/view/<int:id>")
48 def rodelbahn_view(id):
50 return RodelbahnController().view(id)
53 @app.route("/rodelbahn/update")
54 def rodelbahn_update():
56 return RodelbahnController().update()
59 @app.route("/rodelbahn/update_regioncache")
60 def rodelbahn_update_regioncache():
62 return RodelbahnController().update_regioncache()
65 @app.route("/bericht/list")
68 return BerichtController().list()
71 @app.route("/bericht/view/<int:id>")
74 return BerichtController().view(id)
77 @app.route("/bericht/change_date_invalid/<int:id>", methods=['POST'])
78 def bericht_change_date_invalid(id):
80 return BerichtController().view(id)
83 @app.route("/gasthaus/list")
86 return GasthausController().list()
89 @app.route("/gasthaus/view/<int:id>")
90 def gasthaus_view(id):
92 return GasthausController().view(id)
95 @app.route("/gasthaus/update")
96 def gasthaus_update():
98 return GasthausController().update()
101 @app.route("/coordtool/index")
102 def coordtool_index():
103 return CoordtoolController().index()
106 @app.route("/coordtool/convert", methods=['POST'])
107 def coordtool_convert():
108 return CoordtoolController().convert()