diff options
author | Parker <contact@pkrm.dev> | 2024-11-03 23:05:03 -0600 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-11-03 23:05:03 -0600 |
commit | 65fef6274166678f59d6d81c9da68465a7c374bc (patch) | |
tree | 017c3e25748db16496f9ae8e8886665210b14119 /app | |
parent | 179c29b279bcab67eb718601694a4927cb5e8078 (diff) |
Be certain data is present in the response
Diffstat (limited to 'app')
-rw-r--r-- | app/util/log.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/util/log.py b/app/util/log.py index 46687c2..de60f23 100644 --- a/app/util/log.py +++ b/app/util/log.py @@ -32,7 +32,17 @@ def ip_to_location(ip): ) return "-, -", "-" - location = f'{data["country_name"]}, {data["city_name"]}' + location = "" + # Sometimes a certain name may not be present, so always check + if "city_name" in data: + location += data["city_name"] + + if "region_name" in data: + location += f', {data["region_name"]}' + + if "country_name" in data: + location += f', {data["country_name"]}' + isp = data["as"] return location, isp |