diff --git a/api/config.py b/api/config.py new file mode 100644 index 0000000..8705346 --- /dev/null +++ b/api/config.py @@ -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!") + + + + diff --git a/config/config.json.example b/config/config.json.example new file mode 100644 index 0000000..e9bd579 --- /dev/null +++ b/config/config.json.example @@ -0,0 +1,3 @@ +{ + "key" : "INSERTKEYHERE" +}