from flask import Flask from flask_admin import Admin from flask_security import Security, SQLAlchemyUserDatastore from flask_security.models import fsqla_v2 as fsqla from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from .config import set_config app = Flask(__name__) set_config(app) # Setup Flask-SQLAlchemy db = SQLAlchemy(app) fsqla.FsModels.set_db_info(db) # Setup Flask-Migrate migrate = Migrate(app, db) # Setup Flask-Admin from .custom_classes import SecureAdminIndexView, SecureAssistantIndexView adminSpace = Admin( app, name="Admin@AdvLabDB", url="/admin", template_mode="bootstrap3", index_view=SecureAdminIndexView(name="Home", url="/admin", endpoint="admin"), ) assistantSpace = Admin( app, name="Assistant@AdvLabDB", url="/assistant", template_mode="bootstrap3", index_view=SecureAssistantIndexView(name="Home", url="/assistant", endpoint="assistant"), ) from . import models user_datastore = SQLAlchemyUserDatastore(db, models.User, models.Role) Security(app, user_datastore) try: from . import routes, adminModelViews, assistantModelViews except Exception as ex: print( "\nYou are probably initializing the database with a script. If not, then you have to worry about not being able to import in __init__.py!\n" ) print(str(ex))