diff options
Diffstat (limited to 'iot_barcode/config.py')
-rw-r--r-- | iot_barcode/config.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/iot_barcode/config.py b/iot_barcode/config.py new file mode 100644 index 0000000..7435f8b --- /dev/null +++ b/iot_barcode/config.py @@ -0,0 +1,24 @@ + + +"""Module to read the Configuration File for the Service""" + + +import sys +import json + +from iot_barcode.static import CONFIG_PATH + + +def get_config(): + """Read Config File and return it as Python Object""" + + try: + with open(CONFIG_PATH, "r") as config_file: + text = config_file.read() + except FileNotFoundError: + print("Config file does not exist.") + sys.exit(1) + + data = json.loads(text) + + return data |