Support loading config via env var
In addition to loading the config via a `config.json` file, this change allows it to be loaded via an environment variable called `CZDS_CONFIG`. This makes it straightforward to deploy to services like Heroku, which tend to use env vars for config. See https://12factor.net/ for details.
This commit is contained in:
parent
6c082c8fe4
commit
d2cc85b697
|
@ -12,6 +12,10 @@ from do_http_get import do_get
|
||||||
##############################################################################################################
|
##############################################################################################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if 'CZDS_CONFIG' in os.environ:
|
||||||
|
config_data = os.environ['CZDS_CONFIG']
|
||||||
|
config = json.loads(config_data)
|
||||||
|
else:
|
||||||
config_file = open("config.json", "r")
|
config_file = open("config.json", "r")
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
config_file.close()
|
config_file.close()
|
||||||
|
|
Loading…
Reference in a new issue