misp-modules/website/app/__init__.py

37 lines
862 B
Python
Raw Normal View History

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-07 14:39:19 +01:00
from config import config as Config
import os
db = SQLAlchemy()
csrf = CSRFProtect()
migrate = Migrate()
2024-02-12 15:36:38 +01:00
sess = Session()
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
sess.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-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-07 14:39:19 +01:00
return app