Fix json addressing
This commit is contained in:
parent
c43acf2d1c
commit
70e5f99832
2 changed files with 12 additions and 11 deletions
|
@ -5,7 +5,7 @@ env_DEBUG = os.environ.get("DEBUG", "").lower() == "true"
|
||||||
|
|
||||||
env_SECURE = os.environ.get("SECURE", "").lower() == "true"
|
env_SECURE = os.environ.get("SECURE", "").lower() == "true"
|
||||||
env_OWM_KEY = os.environ.get("OWM_API_KEY", "")
|
env_OWM_KEY = os.environ.get("OWM_API_KEY", "")
|
||||||
env_OWM_UNITS = os.environ.get("OWM_UNITS", "")
|
env_OWM_UNITS = os.environ.get("OWM_UNITS", "standard")
|
||||||
env_AUTHORIZED_CALLERS = list(os.environ.get("AUTHORIZED_CALLERS", ""))
|
env_AUTHORIZED_CALLERS = list(os.environ.get("AUTHORIZED_CALLERS", ""))
|
||||||
env_SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(24))
|
env_SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(24))
|
||||||
if not env_SECRET_KEY:
|
if not env_SECRET_KEY:
|
||||||
|
|
21
app/utils.py
21
app/utils.py
|
@ -65,16 +65,16 @@ def _get_weather(lat, long):
|
||||||
return "An error has occured and the weather could not be retrieved."
|
return "An error has occured and the weather could not be retrieved."
|
||||||
|
|
||||||
weather = weather_template.format(
|
weather = weather_template.format(
|
||||||
weather_json.current.temp,
|
weather_json["current"]["temp"],
|
||||||
weather_json.current.feels_like,
|
weather_json["current"]["feels_like"],
|
||||||
weather_json.daily[0].temp.max,
|
weather_json["daily"][0]["temp"]["max"],
|
||||||
weather_json.daily[0].temp.min,
|
weather_json["daily"][0]["temp"]["min"],
|
||||||
weather_json.current.humidity,
|
weather_json["current"]["humidity"],
|
||||||
weather_json.daily[0].summary,
|
weather_json["daily"][0]["summary"],
|
||||||
)
|
)
|
||||||
return weather
|
return weather
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Error in _get_weather: " + e)
|
logger.error("Error in _get_weather: " + str(e))
|
||||||
return "An error has occured and the weather could not be retrieved."
|
return "An error has occured and the weather could not be retrieved."
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ def _get_weather_json(lat, long):
|
||||||
logger.error("Error in _get_weather_json: " + str(response.status_code))
|
logger.error("Error in _get_weather_json: " + str(response.status_code))
|
||||||
return None
|
return None
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
logger.error("Error in _get_weather_json: " + e)
|
logger.error("Error in _get_weather_json: " + str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,10 +107,11 @@ def _get_cords(zipcode):
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
locale = response.json()
|
locale = response.json()
|
||||||
return locale.lat, locale.long
|
logger.info(locale)
|
||||||
|
return locale["lat"], locale["lon"]
|
||||||
else:
|
else:
|
||||||
logger.error("Error in _get_cords: " + str(response.status_code))
|
logger.error("Error in _get_cords: " + str(response.status_code))
|
||||||
return None, None
|
return None, None
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
logger.error("Error in _get_cords: " + e)
|
logger.error("Error in _get_cords: " + str(e))
|
||||||
return None, None
|
return None, None
|
||||||
|
|
Loading…
Reference in a new issue