2024-02-07 14:39:19 +01:00
|
|
|
from flask import Flask
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
from flask_wtf import CSRFProtect
|
|
|
|
from flask_migrate import Migrate
|
2024-02-12 15:36:38 +01:00
|
|
|
from flask_session import Session
|
2024-02-29 10:15:16 +01:00
|
|
|
from flask_login import LoginManager
|
2024-02-07 14:39:19 +01:00
|
|
|
|
2024-03-05 11:30:58 +01:00
|
|
|
from conf.config import config as Config
|
2024-02-07 14:39:19 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
db = SQLAlchemy()
|
|
|
|
csrf = CSRFProtect()
|
|
|
|
migrate = Migrate()
|
2024-02-29 10:15:16 +01:00
|
|
|
session = Session()
|
|
|
|
login_manager = LoginManager()
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
def create_app():
|
|
|
|
app = Flask(__name__)
|
|
|
|
config_name = os.environ.get("FLASKENV")
|
|
|
|
|
|
|
|
app.config.from_object(Config[config_name])
|
|
|
|
|
|
|
|
Config[config_name].init_app(app)
|
|
|
|
|
|
|
|
db.init_app(app)
|
|
|
|
csrf.init_app(app)
|
|
|
|
migrate.init_app(app, db, render_as_batch=True)
|
2024-02-12 15:36:38 +01:00
|
|
|
app.config["SESSION_SQLALCHEMY"] = db
|
2024-02-29 10:15:16 +01:00
|
|
|
session.init_app(app)
|
|
|
|
login_manager.login_view = "account.login"
|
|
|
|
login_manager.init_app(app)
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
from .home import home_blueprint
|
2024-02-15 15:33:41 +01:00
|
|
|
from .history.history import history_blueprint
|
2024-02-29 10:15:16 +01:00
|
|
|
from .account.account import account_blueprint
|
2024-02-07 14:39:19 +01:00
|
|
|
app.register_blueprint(home_blueprint, url_prefix="/")
|
2024-02-15 15:33:41 +01:00
|
|
|
app.register_blueprint(history_blueprint, url_prefix="/")
|
2024-02-29 10:15:16 +01:00
|
|
|
app.register_blueprint(account_blueprint, url_prefix="/")
|
2024-05-16 14:32:49 +02:00
|
|
|
csrf.exempt(home_blueprint)
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
return app
|
|
|
|
|