124def response(resp):
125 location = weather.GeoLocation.by_query(resp.search_params["query"])
126
127 res = EngineResults()
128 json_data = resp.json()
129
130 weather_answer = WeatherAnswer(
131 current=_weather_data(location, json_data["current"]),
132 service="Open-meteo",
133
134 )
135
136 for index, time in enumerate(json_data["hourly"]["time"]):
137
138 if time < json_data["current"]["time"]:
139
140 continue
141
142 hourly_data = {}
143 for key in data_of_interest:
144 hourly_data[key] = json_data["hourly"][key][index]
145
146 forecast_data = _weather_data(location, hourly_data)
147 forecast_data.datetime = weather.DateTime(datetime.fromtimestamp(time))
148 weather_answer.forecasts.append(forecast_data)
149
150 res.add(weather_answer)
151 return res