Capture and return region from geoip lookup

gregdan3/master
Gregory Danielson 4 years ago
parent 859756cd8b
commit 0056a97386
No known key found for this signature in database
GPG Key ID: 88D4EF22F6C14CA7

@ -158,11 +158,13 @@ def geoip(ip_addr):
try:
response = GEOIP_READER.city(ip_addr)
country = response.country.name
region = response.subdivisions.name
city = response.city.name
except geoip2.errors.AddressNotFoundError:
country = None
region = None
city = None
return city, country
return city, region, country
def workaround(city, country):
# workaround for the strange bug with the country name

Loading…
Cancel
Save