89def response(resp):
90 results = []
91
92 if resp.status_code == 404:
93 return []
94
95 result = loads(resp.text)
96
97 current = result["current_condition"][0]
98 location = result['nearest_area'][0]
99
100 forecast_indices = {3: gettext('Morning'), 4: gettext('Noon'), 6: gettext('Evening'), 7: gettext('Night')}
101
102 title = f"{location['areaName'][0]['value']}, {location['region'][0]['value']}"
103
104 infobox = f"<h3>{gettext('Current condition')}</h3><table><tbody>"
105
106 infobox += generate_condition_table(current, resp.search_params['language'], True)
107
108 infobox += "</tbody></table>"
109
110 for day in result["weather"]:
111 infobox += f"<h3>{day['date']}</h3>"
112
113 infobox += "<table><tbody>"
114
115 infobox += generate_day_table(day)
116
117 infobox += "</tbody></table>"
118
119 infobox += "<table><tbody>"
120
121 for time in forecast_indices.items():
122 infobox += f"<tr><td rowspan=\"7\"><b>{time[1]}</b></td></tr>"
123
124 infobox += generate_condition_table(day['hourly'][time[0]], resp.search_params['language'])
125
126 infobox += "</tbody></table>"
127
128 results.append(
129 {
130 "infobox": title,
131 "content": infobox,
132 }
133 )
134
135 return results