From f209e0e4524f75952f5747810755da4765f3a110 Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Mon, 5 Aug 2024 10:30:45 +0200 Subject: [PATCH 1/2] Changed Endpoint --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 2c3d321..df95677 100644 --- a/src/main.py +++ b/src/main.py @@ -43,7 +43,7 @@ class MinSizePerRequestError(Exception): pass -@api.get('/') +@api.get('/zeros') async def test_data(api_key: str, size: str) -> StreamingResponse: try: if api_key not in AUTHORIZED_KEYS: From 3270e3fe2c38e40695eaf6bd5e86e38d55c3ec02 Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Mon, 5 Aug 2024 10:41:51 +0200 Subject: [PATCH 2/2] Can Also read in API Keys from a file --- src/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.py b/src/main.py index df95677..54a405d 100644 --- a/src/main.py +++ b/src/main.py @@ -26,6 +26,10 @@ BUFFER_SIZE = convert_to_bytes(CONFIG['buffer-size']) MAX_SIZE = convert_to_bytes(CONFIG['max-size']) MAX_DATA = convert_to_bytes(CONFIG['max-data']) AUTHORIZED_KEYS = CONFIG['keys'] +if isinstance(AUTHORIZED_KEYS, str): + with open(AUTHORIZED_KEYS) as file: + AUTHORIZED_KEYS = list( + filter(lambda x: x.strip() != '', file.read().splitlines())) DATABASE = CONFIG['database'] if not exists(DATABASE):