]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/__init__.py
gasthaus_list is rendered now.
[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
11
12 app = Flask(__name__)
13 app.config.from_envvar('WRADMIN_SETTINGS')
14
15
16 def get_db():
17     """Opens a new database connection if there is none yet for the
18     current application context.
19     """
20     if not hasattr(g, 'db'):
21         g.db_engine = create_engine(app.config['DATABASE_URI'])
22         wradmin.model.init_model(g.db_engine)
23         g.db = g.db_engine.connect()
24     return g.db
25
26
27 @app.teardown_appcontext
28 def close_db(error):
29     """Closes the database again at the end of the request."""
30     if hasattr(g, 'db'):
31         g.db.close()
32
33
34 @app.route("/")
35 def index():
36     return render_genshi_template('index.html')
37
38
39 @app.route("/rodelbahn/list")
40 def rodelbahn_list():
41     get_db()
42     return RodelbahnController().list()
43
44
45 @app.route("/rodelbahn/update")
46 def rodelbahn_update():
47     pass
48
49
50 @app.route("/rodelbahn/view/<int:id>")
51 def rodelbahn_view(id):
52     pass
53
54
55 @app.route("/rodelbahn/update_regioncache")
56 def rodelbahn_update_regioncache():
57     pass
58
59
60 @app.route("/bericht/list")
61 def bericht_list():
62     pass
63
64
65 @app.route("/gasthaus/list")
66 def gasthaus_list():
67     get_db()
68     return GasthausController().list()
69
70
71 @app.route("/gasthaus/view/<int:id>")
72 def gasthaus_view():
73     get_db()
74     return GasthausController().view(id)
75
76
77 @app.route("/gasthaus/update")
78 def gasthaus_update():
79     get_db()
80     return GasthausController().update()
81
82
83 @app.route("/coordtool/index")
84 def coordtool_index():
85     pass