refactor: reorganized code

This commit is contained in:
Prof. Dr. Matthias Jung DL9MJ
2025-06-24 22:04:10 +02:00
committed by Tim Grelka
parent b61efacbbc
commit 0d39b76b7d
2 changed files with 2 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import json
import os
class Config:
def __init__(self):
self.access_token = None
if os.path.isfile("config/config.json") :
with open ("config/config.json") as fh:
config_doc = json.load(fh)
self.access_token = config_doc["key"]
elif 'DIRECTUS_API_KEY' in os.environ.keys():
self.access_token = os.environ['DIRECTUS_API_KEY']
else:
raise Exception("ERROR: Cannot find API key in config or environment!")
if 'DIRECTUS_BASEURL' in os.environ.keys():
self.base_url = os.environ['DIRECTUS_BASEURL']
else:
self.base_url = "https://fragenkatalog.darc.de/"
if not self.access_token:
raise Exception("ERROR: Cannot find API key in config or environment!")