diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a26d767 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +OSDG_API_URL=http://20.73.166.85/label_text +AURORA_API_URL=https://aurora-sdg.labs.vu.nl/classifier/classify/elsevier-sdg-multi +OSDG_TOKEN= +GITHUB_TOKEN= diff --git a/README.md b/README.md index ac57d22..f3b96a8 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ cd backend python3 -m venv myvenv source ./myvenv/bin/activate pip install -r requirements.txt +cp .env.example .env +# Update values if needed before starting backend python3 app.py ``` diff --git a/backend/app.py b/backend/app.py index 951a1f9..320df98 100644 --- a/backend/app.py +++ b/backend/app.py @@ -9,6 +9,10 @@ from embedding_url import main as classify_url from aurora_api import main as aurora_classify +OSDG_API_URL = os.environ.get( + "OSDG_API_URL", + "http://20.73.166.85/label_text" +) app = Flask(__name__) CORS(app) @@ -175,7 +179,7 @@ def osdg_external_api(): # Call the external OSDG API try: osdg_response = requests.post( - "http://20.73.166.85/label_text", + OSDG_API_URL, json={ "text": projectDescription }, diff --git a/backend/aurora_api.py b/backend/aurora_api.py index e31b1b3..c733cf7 100644 --- a/backend/aurora_api.py +++ b/backend/aurora_api.py @@ -1,4 +1,5 @@ import requests +import os import json from sdg_constants import SDG_LABELS_DICT as SDG_LABELS @@ -16,7 +17,10 @@ def main(text: str, project_name: str = None, project_url: str = None): Dictionary with predictions in standardized format """ try: - url = "https://aurora-sdg.labs.vu.nl/classifier/classify/elsevier-sdg-multi" + url = os.environ.get( + "AURORA_API_URL", + "https://aurora-sdg.labs.vu.nl/classifier/classify/elsevier-sdg-multi" + ) payload = json.dumps({"text": text}) headers = {'Content-Type': 'application/json'} response = requests.request("POST", url, headers=headers, data=payload)