# http://flask.pocoo.org/ # FLASK_APP=wradmin FLASK_DEBUG=1 WRADMIN_SETTINGS=development.cfg python3 -m flask run # FLASK_APP=wradmin WRADMIN_SETTINGS=production.cfg python3 -m flask run from flask import Flask, send_from_directory, abort, g from sqlalchemy.engine import create_engine import wradmin.model from wradmin.genshi import render_genshi_template from wradmin.controllers.rodelbahn import RodelbahnController app = Flask(__name__) app.config.from_envvar('WRADMIN_SETTINGS') def get_db(): """Opens a new database connection if there is none yet for the current application context. """ if not hasattr(g, 'db'): g.db_engine = create_engine(app.config['DATABASE_URI']) wradmin.model.init_model(g.db_engine) g.db = g.db_engine.connect() return g.db @app.teardown_appcontext def close_db(error): """Closes the database again at the end of the request.""" if hasattr(g, 'db'): g.db.close() @app.route("/") def index(): return render_genshi_template('index.html') @app.route("/rodelbahn/list") def rodelbahn_list(): get_db() return RodelbahnController().list() @app.route("/rodelbahn/update") def rodelbahn_update(): pass @app.route("/rodelbahn/view/") def rodelbahn_view(id): pass @app.route("/rodelbahn/update_regioncache") def rodelbahn_update_regioncache(): pass @app.route("/bericht/list") def bericht_list(): pass @app.route("/gasthaus/list") def gasthaus_list(): pass @app.route("/coordtool/index") def coordtool_index(): pass