Matchplan/flaskapp/app.py

53 lines
1.0 KiB
Python
Raw Normal View History

2021-05-08 05:29:32 +02:00
from flaskapp.config.secret import secret
from flaskapp.lib import csrf
from flask import Flask, redirect, url_for, session
from datetime import timedelta
from flaskapp.blueprints import index, login, tournament
app = Flask(__name__)
@app.errorhandler(404)
def page_not_found(e):
return redirect(url_for('index.index'))
@app.before_request
def set_session_timeout():
session.permanent = True
app.permanent_session_lifetime = timedelta(minutes=20)
def configure_app(app):
app.secret_key = secret['secret_key']
def init_jinja(app):
app.jinja_env.globals.update(len=len)
app.jinja_env.globals.update(str=str)
app.jinja_env.globals.update(enumerate=enumerate)
def init_app(app):
configure_app(app)
csrf.csrf.init_app(app)
init_jinja(app)
def register_blueprints():
app.register_blueprint(index.bp)
app.register_blueprint(tournament.bp)
app.register_blueprint(login.bp)
def start():
init_app(app)
register_blueprints()
start()
if __name__ == '__main__':
app.run()