]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/__init__.py
Change to jinja2: index.html is now rendered with jinja2 (no styling yet).
[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, render_template
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 app.jinja_env.globals.update(h=wradmin.genshi.PylonsHelper())
18
19
20 @app.teardown_appcontext
21 def remove_db_session(error):
22     """Removes the database session at the end of the request."""
23     wradmin.model.meta.Session.remove()
24
25
26 @app.route("/")
27 def index():
28     return render_template('index.html')
29
30
31 @app.route("/rodelbahn/list")
32 def rodelbahn_list():
33     return RodelbahnController().list()
34
35
36 @app.route("/rodelbahn/view/<int:id>")
37 def rodelbahn_view(id):
38     return RodelbahnController().view(id)
39
40
41 @app.route("/rodelbahn/update")
42 def rodelbahn_update():
43     return RodelbahnController().update()
44
45
46 @app.route("/rodelbahn/update_regioncache")
47 def rodelbahn_update_regioncache():
48     return RodelbahnController().update_regioncache()
49
50
51 @app.route("/bericht/list")
52 def bericht_list():
53     return BerichtController().list()
54
55
56 @app.route("/bericht/view/<int:id>")
57 def bericht_view(id):
58     return BerichtController().view(id)
59
60
61 @app.route("/bericht/change_date_invalid/<int:id>", methods=['POST'])
62 def bericht_change_date_invalid(id):
63     return BerichtController().change_date_invalid(id)
64
65
66 @app.route("/gasthaus/list")
67 def gasthaus_list():
68     return GasthausController().list()
69
70
71 @app.route("/gasthaus/view/<int:id>")
72 def gasthaus_view(id):
73     return GasthausController().view(id)
74
75
76 @app.route("/gasthaus/update")
77 def gasthaus_update():
78     return GasthausController().update()
79
80
81 @app.route("/coordtool/index")
82 def coordtool_index():
83     return CoordtoolController().index()
84
85
86 @app.route("/coordtool/convert", methods=['POST'])
87 def coordtool_convert():
88     return CoordtoolController().convert()