diff options
author | Marius Peter <marius.peter@tutanota.com> | 2022-05-15 13:17:58 +0200 |
---|---|---|
committer | Marius Peter <marius.peter@tutanota.com> | 2022-05-15 13:17:58 +0200 |
commit | 80e2e45dde6d52f9ecc3a15804dc852be566b3b9 (patch) | |
tree | 8aac9bc0a9d3bc2075c403debba45441bea93709 /app | |
parent | e084f90c19e779592f6e3f14eb8f70a7287f0dad (diff) |
Flask factory!
Diffstat (limited to 'app')
-rw-r--r-- | app/__init__.py | 40 |
1 files changed, 40 insertions, 0 deletions
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 |