aboutsummaryrefslogtreecommitdiff
path: root/app/util/log.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-03 23:05:03 -0600
committerParker <contact@pkrm.dev>2024-11-03 23:05:03 -0600
commit65fef6274166678f59d6d81c9da68465a7c374bc (patch)
tree017c3e25748db16496f9ae8e8886665210b14119 /app/util/log.py
parent179c29b279bcab67eb718601694a4927cb5e8078 (diff)
Be certain data is present in the response
Diffstat (limited to 'app/util/log.py')
-rw-r--r--app/util/log.py12
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