36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
|
|
from flask import Flask, render_template, g, session
|
|
from wotstats.database import db, migrate
|
|
from wotstats.openid import oid
|
|
from wotstats.views.home import pages_home
|
|
from wotstats.views.account import pages_account
|
|
|
|
def init_app():
|
|
app = Flask(__name__)
|
|
app.debug = True
|
|
app.config['SECRET_KEY'] = 'super-secret'
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://wot:wot@192.168.1.47/wot'
|
|
app.config['OPENID_FS_STORE_PATH'] = 'tmp'
|
|
#
|
|
app.config['WG_ID'] = '502910c1c785c3c7ca2e83c9e89bde02'
|
|
app.config['WG_OPENID_URL'] = 'https://eu.wargaming.net/id/openid/'
|
|
|
|
# , safe_roots=[]
|
|
oid.init_app(app)
|
|
db.init_app(app)
|
|
migrate.init_app(app, db)
|
|
# jwt = JWT(app, authenticate, identity)
|
|
|
|
app.register_blueprint(pages_home)
|
|
app.register_blueprint(pages_account)
|
|
|
|
@app.before_request
|
|
def lookup_current_user():
|
|
from wotstats.models import User
|
|
|
|
g.user = None
|
|
if 'openid' in session:
|
|
openid = session['openid']
|
|
g.user = User.query.filter_by(openid=openid).first()
|
|
|
|
return app
|