diff --git a/compendium_v2/__init__.py b/compendium_v2/__init__.py index 7fa8548147f3ba486bf9d6ddd7a5849dd2db33fd..f30107f00e00ff8879cdbc9431e9de4c6db20233 100644 --- a/compendium_v2/__init__.py +++ b/compendium_v2/__init__.py @@ -37,15 +37,6 @@ def _create_app(app_config) -> Flask: app = Flask(__name__) CORS(app) - app.config['CONFIG_PARAMS'] = app_config - app.config['SECRET_KEY'] = app_config['SECRET_KEY'] - app.config['SESSION_COOKIE_SECURE'] = True - if 'oidc' not in app_config: - app.config['LOGIN_DISABLED'] = True - logger.info('No OIDC configuration found, authentication disabled') - else: - logger.info('OIDC configuration found, authentication will be enabled') - from compendium_v2.routes import default app.register_blueprint(default.routes, url_prefix='/') @@ -55,6 +46,19 @@ def _create_app(app_config) -> Flask: from compendium_v2.routes import api app.register_blueprint(api.routes, url_prefix='/api') + if not app_config: + # workaround for sphinx causing app to be created, but not loading a config + return app + + app.config['CONFIG_PARAMS'] = app_config + app.config['SECRET_KEY'] = app_config['SECRET_KEY'] + app.config['SESSION_COOKIE_SECURE'] = True + if 'oidc' not in app_config: + app.config['LOGIN_DISABLED'] = True + logger.info('No OIDC configuration found, authentication disabled') + else: + logger.info('OIDC configuration found, authentication will be enabled') + return app