mirror of
https://github.com/chubin/wttr.in
synced 2025-01-12 03:58:45 +00:00
Change geo ip service
This commit is contained in:
parent
6b050470bc
commit
01787b510c
1 changed files with 2 additions and 2 deletions
|
@ -102,7 +102,7 @@ def _geolocator(location):
|
||||||
if random.random() < 0:
|
if random.random() < 0:
|
||||||
geo = requests.get('%s/%s' % (GEOLOCATOR_SERVICE, location)).text
|
geo = requests.get('%s/%s' % (GEOLOCATOR_SERVICE, location)).text
|
||||||
else:
|
else:
|
||||||
geo = requests.get("http://127.0.0.1:8083/:geo-location?location=%s" % location).text
|
geo = requests.get("http://127.0.0.1:8085/:geo-location?location=%s" % location).text
|
||||||
except requests.exceptions.ConnectionError as exception:
|
except requests.exceptions.ConnectionError as exception:
|
||||||
print("ERROR: %s" % exception)
|
print("ERROR: %s" % exception)
|
||||||
return None
|
return None
|
||||||
|
@ -152,7 +152,7 @@ def _ipcache(ip_addr):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
## Use Geo IP service when available
|
## Use Geo IP service when available
|
||||||
r = requests.get("http://127.0.0.1:8083/:geo-ip-get?ip=%s" % ip_addr)
|
r = requests.get("http://127.0.0.1:8085/:geo-ip-get?ip=%s" % ip_addr)
|
||||||
if r.status_code == 200 and ";" in r.text:
|
if r.status_code == 200 and ";" in r.text:
|
||||||
_, country, region, city, *_ = r.text.split(';')
|
_, country, region, city, *_ = r.text.split(';')
|
||||||
return city, region, country
|
return city, region, country
|
||||||
|
|
Loading…
Reference in a new issue