aboutsummaryrefslogtreecommitdiff
path: root/uploader/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/__init__.py')
-rw-r--r--uploader/__init__.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py
index 734bdcd..e25fc5b 100644
--- a/uploader/__init__.py
+++ b/uploader/__init__.py
@@ -8,7 +8,7 @@ from flask import Flask, request
from flask_session import Session
from cachelib import FileSystemCache
-from gn_libs import jobs
+from gn_libs import jobs as gnlibs_jobs
from uploader.oauth2.client import user_logged_in, authserver_authorise_uri
@@ -54,9 +54,15 @@ def setup_logging(app: Flask) -> Flask:
return __log_gunicorn__(app) if bool(software) else __log_dev__(app)
-def create_app():
- """The application factory"""
+def create_app(config: dir):
+ """The application factory.
+
+ config: dict
+ Useful to override settings in the settings files and environment
+ especially in environments such as testing."""
app = Flask(__name__)
+
+ ### BEGIN: Application configuration
app.config.from_pyfile(
Path(__file__).parent.joinpath("default_settings.py"))
if "UPLOADER_CONF" in os.environ:
@@ -71,6 +77,8 @@ def create_app():
if secretsfile.exists():
# Silently ignore secrets if the file does not exist.
app.config.from_pyfile(secretsfile)
+ app.config.update(config) # Override everything with passed in config
+ ### END: Application configuration
app.config["SESSION_CACHELIB"] = FileSystemCache(
cache_dir=Path(app.config["SESSION_FILESYSTEM_CACHE_PATH"]).absolute(),
@@ -96,5 +104,5 @@ def create_app():
app.register_blueprint(speciesbp, url_prefix="/species")
register_error_handlers(app)
- jobs.init_app(app)
+ gnlibs_jobs.init_app(app)
return app