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
14 app.config.from_envvar('WRADMIN_SETTINGS')
18 """Opens a new database connection if there is none yet for the
19 current application context.
21 if not hasattr(g, 'db'):
22 g.db_engine = create_engine(app.config['DATABASE_URI'])
23 wradmin.model.init_model(g.db_engine)
24 g.db = g.db_engine.connect()
28 @app.teardown_appcontext
30 """Closes the database again at the end of the request."""
37 return render_genshi_template('index.html')
40 @app.route("/rodelbahn/list")
43 return RodelbahnController().list()
46 @app.route("/rodelbahn/view/<int:id>")
47 def rodelbahn_view(id):
49 return RodelbahnController().view(id)
52 @app.route("/rodelbahn/update")
53 def rodelbahn_update():
55 return RodelbahnController().update()
58 @app.route("/rodelbahn/update_regioncache")
59 def rodelbahn_update_regioncache():
61 return RodelbahnController().update()
64 @app.route("/bericht/list")
67 return BerichtController().list()
70 @app.route("/bericht/view/<int:id>")
73 return BerichtController().view(id)
76 @app.route("/bericht/change_date_invalid/<int:id>", methods=['POST'])
77 def bericht_change_date_invalid(id):
79 return BerichtController().view(id)
82 @app.route("/gasthaus/list")
85 return GasthausController().list()
88 @app.route("/gasthaus/view/<int:id>")
89 def gasthaus_view(id):
91 return GasthausController().view(id)
94 @app.route("/gasthaus/update")
95 def gasthaus_update():
97 return GasthausController().update()
100 @app.route("/coordtool/index")
101 def coordtool_index():