misp-modules/website/app/__init__.py

31 lines
633 B
Python

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import CSRFProtect
from flask_migrate import Migrate
from config import config as Config
import os
db = SQLAlchemy()
csrf = CSRFProtect()
migrate = Migrate()
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)
from .home import home_blueprint
app.register_blueprint(home_blueprint, url_prefix="/")
return app