Skip to content

Commit

Permalink
Allow different true values for config vars (#841)
Browse files Browse the repository at this point in the history
* Fixes read_config_bool to allow several true params

* add upper case comment
  • Loading branch information
jacr13 committed Sep 7, 2022
1 parent 32ad39d commit 8f59b7c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8f59b7c

Please sign in to comment.