config location from env

This commit is contained in:
Dmitry Belyaev 2021-09-22 13:03:58 +03:00
parent d37db9fb86
commit b4e04c5e46
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -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