diff options
Diffstat (limited to 'app/__init__.py')
-rw-r--r-- | app/__init__.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..bd18038 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,42 @@ +# -*- mode: python; -*- + +"""This is the application factory. + +When the mdl app package is imported, Flask uses the create_app +function to instantiate the web app. + +""" + +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +from flask_login import LoginManager + +from .models import db + + +def create_app(): + app = Flask(__name__) + app.config.from_pyfile("../config.py") + + db.init_app(app) + + login_manager = LoginManager() + login_manager.login_view = "auth.login" + login_manager.init_app(app) + + from .models import User + + @login_manager.user_loader + def load_user(user_id): + return User.query.get(int(user_id)) + + from .main import main + + app.register_blueprint(main) + + from .modules import common, auth + + app.register_blueprint(common) + app.register_blueprint(auth) + + return app |