diff --git a/application/config.py b/application/config.py index 737bacf9..8459f820 100644 --- a/application/config.py +++ b/application/config.py @@ -1,6 +1,7 @@ import os basedir = os.path.abspath(os.path.dirname(__file__)) +ENABLE_MYOPENCRE = os.getenv("ENABLE_MYOPENCRE", "false").lower() == "true" class Config: diff --git a/application/web/web_main.py b/application/web/web_main.py index 3837792d..29567470 100644 --- a/application/web/web_main.py +++ b/application/web/web_main.py @@ -22,6 +22,7 @@ from application.cmd import cre_main from application.defs import cre_defs as defs from application.defs import cre_exceptions +from application.config import ENABLE_MYOPENCRE from application.utils import spreadsheet as sheet_utils from application.utils import mdutils, redirectors, gap_analysis @@ -825,8 +826,15 @@ def all_cres() -> Any: # Importing Handlers +@app.route("/api/capabilities") +def capabilities(): + return jsonify({"myopencre": ENABLE_MYOPENCRE}) + + @app.route("/rest/v1/cre_csv", methods=["GET"]) def get_cre_csv() -> Any: + if not ENABLE_MYOPENCRE: + abort(404) if posthog: posthog.capture(f"get_cre_csv", "") @@ -854,6 +862,9 @@ def get_cre_csv() -> Any: @app.route("/rest/v1/cre_csv_import", methods=["POST"]) def import_from_cre_csv() -> Any: + if not ENABLE_MYOPENCRE: + abort(404) + if not os.environ.get("CRE_ALLOW_IMPORT"): abort( 403,