def weather(request, city):
"""
Returns weather information from a particular city
"""
if city is None:
return APIException("Missing city parameter")
try:
weather_provider_class = utils.get_setting('WEATHER_PROVIDER')
weather_provider = utils.module_member(weather_provider_class)
provider_instance = weather_provider()
res = provider_instance.get_weather_data(city)
except ApiCallFailed:
return Response(status=status.HTTP_404_NOT_FOUND)
return Response(res)
评论列表
文章目录