diff --git a/microservice/helper.py b/microservice/helper.py index 249ba730..886a01c7 100644 --- a/microservice/helper.py +++ b/microservice/helper.py @@ -3,7 +3,8 @@ DEFAULT_HOOK_EP = "enpointforhook" DEFAULT_API_KEY = "readdocshowtoget" -API_ENDPOINT = "https://cocktailberryapi-1-u0613408.deta.app/cocktail" +OLD_API_ENDPOINT = "https://cocktailberryapi-1-u0613408.deta.app/cocktail" +API_ENDPOINT = "https://api.cocktailberry.org/api/v1/cocktail" def generate_urls_and_headers() -> List[Tuple[str, Dict[str, str]]]: @@ -13,9 +14,7 @@ def generate_urls_and_headers() -> List[Tuple[str, Dict[str, str]]]: hook_headers_config = os.getenv("HOOK_HEADERS", None) if hook_headers_config is None: # If no headers are set, use common content type - hook_headers = { - "content-type": "application/json" - } + hook_headers = {"content-type": "application/json"} else: # Split the header config into a list # the config is header:value,header2:value2 @@ -29,8 +28,18 @@ def generate_urls_and_headers() -> List[Tuple[str, Dict[str, str]]]: use_api = (api_key != DEFAULT_API_KEY) and (api_key is not None) endpoint_data = [] if use_hook: - endpoint_data.append((hook_url, hook_headers,)) + endpoint_data.append( + ( + hook_url, + hook_headers, + ) + ) if use_api: - endpoint_data.append((API_ENDPOINT, api_headers,)) + endpoint_data.append( + ( + API_ENDPOINT, + api_headers, + ) + ) return endpoint_data diff --git a/microservice/query_sender.py b/microservice/query_sender.py index c6af42a9..fba1b7bb 100644 --- a/microservice/query_sender.py +++ b/microservice/query_sender.py @@ -3,6 +3,8 @@ from flask import Flask from database import DatabaseHandler +from helper import API_ENDPOINT, OLD_API_ENDPOINT + def try_send_query_data(app: Flask): db_handler = DatabaseHandler() @@ -13,6 +15,9 @@ def try_send_query_data(app: Flask): # Else try to send all remaining data app.logger.info("Found some not sended data, trying to send ...") for send_id, data, url, headers in failed_data: + # overwrite old endpoint + if url == OLD_API_ENDPOINT: + url = API_ENDPOINT try: res = requests.post(url, data=data, headers=json.loads(headers), timeout=10) app.logger.info(f"Code: {res.status_code}, to: {url}, Payload: {data}") diff --git a/pyproject.toml b/pyproject.toml index 52968708..a9365e29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "CocktailBerry" -version = "1.36.0" +version = "1.36.1" description = "A Python and Qt based App for a Cocktail Machine on a Raspberry Pi. Easily serve Cocktails with Raspberry Pi and Python" authors = [{ name= "Andre Wohnsland" , email = "Andre_Wohnsland@web.de" }] readme = "readme.md" diff --git a/src/__init__.py b/src/__init__.py index e2f7ee19..ff8fc9d8 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,6 +1,6 @@ from typing import Literal -__version__ = "1.36.0" +__version__ = "1.36.1" PROJECT_NAME = "CocktailBerry" MAX_SUPPORTED_BOTTLES = 24 SupportedLanguagesType = Literal["en", "de"]