aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-03-12 15:59:42 +0300
committerFrederick Muriuki Muriithi2024-03-12 15:59:42 +0300
commitbf4f7c56a49a243a3f9e3ed32cea313e8456bafc (patch)
treeba44379bfeb221c6e14fabacb9701375957c74fb /qc_app
parente152c8dd8694810d7d4c8cbbd241e80ff2b5c565 (diff)
downloadgn-uploader-bf4f7c56a49a243a3f9e3ed32cea313e8456bafc.tar.gz
Build up correct path to default settings
The assumption has been that the application will be started in the root of the repository, and uses that to source the default settings. It is, however, possible that the application is started in a totally different working directory, which leads to an error during startup. This commit sources the default settings relative to a know file, in this case the module __init__.py file for qc_app module.
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/qc_app/__init__.py b/qc_app/__init__.py
index b40ec46..e44f471 100644
--- a/qc_app/__init__.py
+++ b/qc_app/__init__.py
@@ -1,6 +1,7 @@
"""The Quality-Control Web Application entry point"""
import os
+from pathlib import Path
from flask import Flask
@@ -20,7 +21,8 @@ def override_settings_with_envvars(
def create_app():
"""The application factory"""
app = Flask(__name__)
- app.config.from_pyfile(os.path.join(os.getcwd(), "etc/default_config.py"))
+ app.config.from_pyfile(os.path.join(
+ Path(__file__).parent.parent, "etc/default_config.py"))
if "QCAPP_CONF" in os.environ:
app.config.from_envvar("QCAPP_CONF") # Override defaults with instance path