1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +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 import Flask
from flask_admin import Admin from flask_admin import Admin
from flask_security import Security, SQLAlchemyUserDatastore from flask_security import Security, SQLAlchemyUserDatastore
from flask_security.models import fsqla_v2 as fsqla from flask_security.models import fsqla_v2 as fsqla
from flask_sqlalchemy import SQLAlchemy 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 = Flask(__name__)
app.debug = True # DEBUG
app.config["SECURITY_EMAIL_VALIDATOR_ARGS"] = { app.config["SECURITY_EMAIL_VALIDATOR_ARGS"] = {
"check_deliverability": False "check_deliverability": parse_bool(environ["CHECK_EMAIL_DELIVERABILITY"])
} # Don't check email deliverability # DEBUG }
app.config["SERVER_NAME"] = "127.0.0.1:5000" # DEBUG set_from_env(app, "SERVER_NAME")
# app.config["SERVER_NAME"] = "fprdb.physik.uni-mainz.de:5000" # DEBUG
app.config["SECRET_KEY"] = "dev" set_from_env(app, "SECRET_KEY")
app.config["SECURITY_PASSWORD_SALT"] = "devSalt" # os.environ.get("SECURITY_PASSWORD_SALT", "") 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["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["FLASK_ADMIN_FLUID_LAYOUT"] = True app.config["FLASK_ADMIN_FLUID_LAYOUT"] = True