diff --git a/apps/python-geoweather/app.py b/apps/python-geoweather/app.py index 68ff862..33d1ca3 100644 --- a/apps/python-geoweather/app.py +++ b/apps/python-geoweather/app.py @@ -14,10 +14,10 @@ def get_public_ip(): return response.text.strip() except requests.HTTPError as http_err: logging.error(f'HTTP error occurred: {http_err}') # HTTP error - return f"Unable to get public IP: HTTP error occurred: {http_err}" + return "Unable to get public IP due to an HTTP error." except Exception as err: logging.error(f'Other error occurred: {err}') # Other errors - return f"Unable to get public IP: Other error occurred: {err}" + return "Unable to get public IP due to an unexpected error." def get_location(ip): url = f"https://ipwho.is/{ip}?fields=country,city,latitude,longitude" @@ -27,10 +27,10 @@ def get_location(ip): return response.json() except requests.HTTPError as http_err: logging.error(f'HTTP error occurred while fetching location: {http_err}') - return {'error': f"HTTP error occurred: {http_err}"} + return {'error': "Unable to fetch location due to an HTTP error."} except Exception as err: logging.error(f'Error fetching location: {err}') - return {'error': f"Other error occurred: {err}"} + return {'error': "Unable to fetch location due to an unexpected error."} def get_weather(lat, lon): url = f"https://api.open-meteo.com/v1/forecast?latitude={lat}&longitude={lon}¤t=temperature_2m&forecast_days=1" @@ -40,10 +40,10 @@ def get_weather(lat, lon): return response.json() except requests.HTTPError as http_err: logging.error(f'HTTP error occurred while fetching weather: {http_err}') - return {'error': f"HTTP error occurred: {http_err}"} + return {'error': "Unable to fetch weather due to an HTTP error."} except Exception as err: logging.error(f'Error fetching weather: {err}') - return {'error': f"Other error occurred: {err}"} + return {'error': "Unable to fetch weather due to an unexpected error."} @app.route('/') def index():