Closed Tim-Abwao closed 4 years ago
Thanks for raising this issue. One solution is to keep our current service but properly handle a situation where no location data was found.
Can we reproduce the error? Do you have any IP address ranges where this fails?
@Tim-Abwao thanks for the use-case relevant to this error.
I believe its better to fetch the lat long from the city-country name pair using geopy
IF they are null in the first place.a try except
block in the get_location
function should do the trick!
@gammaG2 I've tried an alternative geo-location API (in #10) which seems reliable so far with latitude and longitude data. It was simple to just switch the URL and a few lines of code.
Seems straight forward!
I think irrespective of which API we use, there is a possibility that the api response might be something unexpected once in a blue moon.
To address such issues, would a decorator function be a good idea to handle exceptions in each of the api dependant feature functions? @xofbd @Tim-Abwao
Good conversations going one.
Crazy how it doesn't show the lat and lon for Nairobi, a city with several million people! Anyways I recommend:
utils.py
file.
https://ipapi.co/{ip_address}/json
sometimes returnsnull
for longitude and latitude. e.g.This then causes problems because the weather API requires longitude and latitude values. With the 'null' location values, the weather API returns
which causes an Internal Server Error in the app, with error message
A possible alternative location API is http://ip-api.com/