Allow people to run commands like "flask db upgrade" without setting specific environment variables like FLASK_SESSION_SECRET_KEY everytime - they just need to add in their own /instance/config.py with their local configuration.

This commit is contained in:
Dan 2023-02-19 10:37:00 -05:00
parent 28ac9ef872
commit 6e7f36e55f
3 changed files with 12 additions and 7 deletions

View File

@ -94,13 +94,6 @@ def create_app() -> flask.app.Flask:
app.config["CONNEXION_APP"] = connexion_app
app.config["SESSION_TYPE"] = "filesystem"
if os.environ.get("FLASK_SESSION_SECRET_KEY") is None:
raise KeyError(
"Cannot find the secret_key from the environment. Please set"
" FLASK_SESSION_SECRET_KEY"
)
app.secret_key = os.environ.get("FLASK_SESSION_SECRET_KEY")
setup_config(app)
db.init_app(app)

View File

@ -129,6 +129,14 @@ def setup_config(app: Flask) -> None:
"SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR config must be set"
)
if app.config["FLASK_SESSION_SECRET_KEY"] is None:
raise KeyError(
"Cannot find the secret_key from the environment. Please set"
" FLASK_SESSION_SECRET_KEY"
)
app.secret_key = os.environ.get("FLASK_SESSION_SECRET_KEY")
app.config["PROCESS_UUID"] = uuid.uuid4()
setup_database_uri(app)

View File

@ -2,6 +2,10 @@
import re
from os import environ
FLASK_SESSION_SECRET_KEY = environ.get(
"FLASK_SESSION_SECRET_KEY"
)
SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR = environ.get(
"SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR"
)