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