View raw

1 # -*- mode: python; -*- 2 3 from flask import Flask 4 from flask_sqlalchemy import SQLAlchemy 5 from flask_login import LoginManager 6 7 from .models import db 8 9 10 def create_app(): 11 app = Flask(__name__) 12 app.config.from_pyfile("../config.py") 13 14 db.init_app(app) 15 16 login_manager = LoginManager() 17 login_manager.login_view = "auth.login" 18 login_manager.init_app(app) 19 20 from .models import User 21 22 @login_manager.user_loader 23 def load_user(user_id): 24 return User.query.get(int(user_id)) 25 26 from .main import main 27 28 app.register_blueprint(main) 29 30 from .modules import common, auth, products, customers, ferti, invoices, orders 31 32 app.register_blueprint(common) 33 app.register_blueprint(auth) 34 app.register_blueprint(products) 35 app.register_blueprint(customers) 36 app.register_blueprint(ferti) 37 app.register_blueprint(invoices) 38 app.register_blueprint(orders) 39 40 # with app.app_context(): 41 # db.create_all() 42 43 return app 44