1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Use dotenv

This commit is contained in:
Mo 2022-04-18 18:04:48 +02:00
parent 11746b8c67
commit ef4c46d535

View file

@ -1,24 +1,34 @@
from os import environ
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 dotenv import load_dotenv
from advlabdb.independent_funs import parse_bool
def set_from_env(app, var):
app.config[var] = environ[var]
load_dotenv(".env")
app = Flask(__name__)
app.debug = True # DEBUG
app.config["SECURITY_EMAIL_VALIDATOR_ARGS"] = {
"check_deliverability": False
} # Don't check email deliverability # DEBUG
"check_deliverability": parse_bool(environ["CHECK_EMAIL_DELIVERABILITY"])
}
app.config["SERVER_NAME"] = "127.0.0.1:5000" # DEBUG
# app.config["SERVER_NAME"] = "fprdb.physik.uni-mainz.de:5000" # DEBUG
set_from_env(app, "SERVER_NAME")
app.config["SECRET_KEY"] = "dev"
app.config["SECURITY_PASSWORD_SALT"] = "devSalt" # os.environ.get("SECURITY_PASSWORD_SALT", "")
set_from_env(app, "SECRET_KEY")
set_from_env(app, "SECURITY_PASSWORD_SALT")
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///../db/advLab.db"
set_from_env(app, "SQLALCHEMY_DATABASE_URI")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["FLASK_ADMIN_FLUID_LAYOUT"] = True