From 8f59b7c3401ec131d37d403e9f7e86bcf5e28d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Wed, 7 Sep 2022 20:54:43 +0200 Subject: [PATCH] Allow different `true` values for config vars (#841) * Fixes read_config_bool to allow several true params * add upper case comment --- app/utils/misc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/utils/misc.py b/app/utils/misc.py index 0ef07c6..9a1b471 100644 --- a/app/utils/misc.py +++ b/app/utils/misc.py @@ -16,9 +16,11 @@ def gen_file_hash(path: str, static_file: str) -> str: def read_config_bool(var: str) -> bool: val = os.getenv(var, '0') - if val.isdigit(): - return bool(int(val)) - return False + # user can specify one of the following values as 'true' inputs (all + # variants with upper case letters will also work): + # ('true', 't', '1', 'yes', 'y') + val = val.lower() in ('true', 't', '1', 'yes', 'y') + return val def get_client_ip(r: Request) -> str: