From 80e2e45dde6d52f9ecc3a15804dc852be566b3b9 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Sun, 15 May 2022 13:17:58 +0200 Subject: Flask factory! --- app/__init__.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/__init__.py diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..3d1bac6 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,40 @@ +# -*- mode: python; -*- + +from flask import Flask +from flask_sqlalchemy import SQLAlchemy +from flask_login import LoginManager + + +db = SQLAlchemy() + + +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, products, customers, ferti, invoices + + app.register_blueprint(common) + app.register_blueprint(auth) + app.register_blueprint(products) + app.register_blueprint(customers) + app.register_blueprint(ferti) + app.register_blueprint(invoices) + + return app -- cgit v1.2.3