43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_login import LoginManager
|
|
from .config import db as db_config
|
|
|
|
db = SQLAlchemy()
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
|
|
app.config['SECRET_KEY'] = '//'
|
|
app.config["SQLALCHEMY_DATABASE_URI"] = db_config.SQL_URI
|
|
|
|
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 . import models
|
|
with app.app_context():
|
|
print("Applying the DB models")
|
|
db.create_all()
|
|
|
|
# blueprint for auth routes in our app
|
|
from .auth import auth as auth_blueprint
|
|
app.register_blueprint(auth_blueprint)
|
|
|
|
# blueprint for non-auth parts of app
|
|
from .main import main as main_blueprint
|
|
app.register_blueprint(main_blueprint)
|
|
|
|
# blueprint for chatbot
|
|
from .chatbot import chatbot as chatbot_blueprint
|
|
app.register_blueprint(chatbot_blueprint)
|
|
|
|
return app
|