2021-03-18 13:53:55 +00:00
|
|
|
from flask import Flask
|
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
2021-04-03 00:11:26 +00:00
|
|
|
from flask_security import Security, SQLAlchemyUserDatastore
|
|
|
|
from flask_security.models import fsqla_v2 as fsqla
|
2021-04-18 23:33:46 +00:00
|
|
|
from flask_admin import Admin
|
|
|
|
#DEBUG
|
|
|
|
from flask_debugtoolbar import DebugToolbarExtension
|
2021-03-18 13:53:55 +00:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
2021-04-18 23:33:46 +00:00
|
|
|
app.debug = True #DEBUG
|
2021-04-03 00:11:26 +00:00
|
|
|
|
2021-03-18 13:53:55 +00:00
|
|
|
app.config["SECRET_KEY"] = "dev"
|
2021-04-03 00:11:26 +00:00
|
|
|
app.config['SECURITY_PASSWORD_SALT'] = "devSalt" # os.environ.get("SECURITY_PASSWORD_SALT", "")
|
|
|
|
|
2021-03-18 13:53:55 +00:00
|
|
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///../advLab.db"
|
|
|
|
db = SQLAlchemy(app)
|
|
|
|
|
2021-04-03 00:11:26 +00:00
|
|
|
fsqla.FsModels.set_db_info(db)
|
|
|
|
|
2021-04-18 23:33:46 +00:00
|
|
|
app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False #DEBUG
|
|
|
|
DebugToolbarExtension(app) #DEBUG
|
|
|
|
|
|
|
|
from advlabdb import customClasses
|
|
|
|
admin = Admin(app, name="Admin@AdvLabDB", template_mode='bootstrap3', index_view=customClasses.AdminIndexView())
|
|
|
|
|
2021-03-18 13:53:55 +00:00
|
|
|
from advlabdb import models
|
2021-04-03 00:11:26 +00:00
|
|
|
|
|
|
|
# Setup Flask-Security
|
|
|
|
user_datastore = SQLAlchemyUserDatastore(db, models.User, models.Role)
|
2021-04-18 23:33:46 +00:00
|
|
|
Security(app, user_datastore)
|
2021-04-03 00:11:26 +00:00
|
|
|
|
|
|
|
from advlabdb import routes
|
2021-03-31 23:04:21 +00:00
|
|
|
from advlabdb import forms
|
2021-04-18 23:33:46 +00:00
|
|
|
from advlabdb import modelViews
|