From 9d9421c6fb28c3185a81adebbbaef4b42c18746f Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 25 Jul 2024 15:09:34 -0500 Subject: Setup secrets from config file. --- uploader/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'uploader') diff --git a/uploader/__init__.py b/uploader/__init__.py index e9875cf..00ed7e7 100644 --- a/uploader/__init__.py +++ b/uploader/__init__.py @@ -30,8 +30,13 @@ def create_app(): override_settings_with_envvars(app, ignore=tuple()) - if "QCAPP_SECRETS" in os.environ: - app.config.from_envvar("QCAPP_SECRETS") + secretsfile = app.config.get("UPLOADER_SECRETS", "").strip() + if bool(secretsfile): + secretsfile = Path(secretsfile).absolute() + app.config["UPLOADER_SECRETS"] = secretsfile + if secretsfile.exists(): + # Silently ignore secrets if the file does not exist. + app.config.from_pyfile(secretsfile) # setup jinja2 symbols app.add_template_global(lambda : request.url, name="request_url") -- cgit v1.2.3