1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00
AdvLabDB/advlabdb/__init__.py
2022-08-09 14:46:48 +02:00

51 lines
1 KiB
Python

from flask_migrate import Migrate
from flask_security import SQLAlchemyUserDatastore
from .config import get_settings
from .models import db, User, Role
migrate = Migrate()
settings = get_settings()
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
def create_app(create_for_server=True):
from flask import Flask
app = Flask(__name__)
# Config
from .config import set_config
set_config(app)
# Setup Flask-SQLAlchemy
db.init_app(app)
# Setup Flask-Migrate
migrate.init_app(app, db)
# Setup Flask-Security-Too
from flask_security import Security
Security(app, user_datastore)
if create_for_server:
# Setup views
from .adminModelViews import init_admin_model_views
init_admin_model_views(app)
from .assistantModelViews import init_assistant_model_views
init_assistant_model_views(app)
# Register blueprints
from .routes import bp as routes_bp
app.register_blueprint(routes_bp)
return app