config location from env
This commit is contained in:
parent
d37db9fb86
commit
b4e04c5e46
@ -155,14 +155,18 @@ url_req_parser = reqparse.RequestParser()
|
|||||||
url_req_parser.add_argument('url', type=str, required=True)
|
url_req_parser.add_argument('url', type=str, required=True)
|
||||||
|
|
||||||
|
|
||||||
def load_config(filename: str = 'config.yml'):
|
def load_config(filename: str):
|
||||||
with open(filename, 'r', encoding='utf-8') as cfg_file:
|
with open(filename, 'r', encoding='utf-8') as cfg_file:
|
||||||
return yaml.safe_load(cfg_file)
|
return yaml.safe_load(cfg_file)
|
||||||
|
|
||||||
|
|
||||||
|
def config_location() -> str:
|
||||||
|
return os.getenv('WEBPUB1C_CONFIG', 'config.yml')
|
||||||
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
if 'config' not in g:
|
if 'config' not in g:
|
||||||
g.config = load_config()
|
g.config = load_config(config_location())
|
||||||
|
|
||||||
return g.config
|
return g.config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user