mirror of
https://github.com/chubin/wttr.in.git
synced 2024-10-05 01:42:07 +02:00
geolocation related fixes
This commit is contained in:
parent
eed7c3597d
commit
a45855fbb4
@ -116,9 +116,13 @@ def get_location(ip_addr):
|
||||
Return location pair (CITY, COUNTRY) for `ip_addr`
|
||||
"""
|
||||
|
||||
response = GEOIP_READER.city(ip_addr)
|
||||
country = response.country.name
|
||||
city = response.city.name
|
||||
try:
|
||||
response = GEOIP_READER.city(ip_addr)
|
||||
country = response.country.name
|
||||
city = response.city.name
|
||||
except geoip2.errors.AddressNotFoundError:
|
||||
country = None
|
||||
city = None
|
||||
|
||||
#
|
||||
# temporary disabled it because of geoip services capcacity
|
||||
|
@ -72,7 +72,7 @@ def render_location(data):
|
||||
location (l)
|
||||
"""
|
||||
|
||||
return data['location']
|
||||
return data['location'].title()
|
||||
|
||||
FORMAT_SYMBOL = {
|
||||
'c': render_condition,
|
||||
|
Loading…
Reference in New Issue
Block a user