diff options
| author | Mitsuo Tokumori <[email protected]> | 2025-03-08 16:03:30 +0900 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2025-03-08 16:03:30 +0900 |
| commit | 51163b167cce01af6101438e5e61145ad798f213 (patch) | |
| tree | 9c8e75266cedfb205db175b0b2bc41b49df75cea /app/static/block_weather.js | |
| parent | d9af103b9a8aed86d6ac834f1240edfb2173ffa0 (diff) | |
| download | masu-51163b167cce01af6101438e5e61145ad798f213.tar.gz masu-51163b167cce01af6101438e5e61145ad798f213.tar.bz2 masu-51163b167cce01af6101438e5e61145ad798f213.zip | |
Restructure python code to be modular
The python code is now a package named app.
app/models: db models
app/routes: flask blueprints
app/static: css, js
app/templates: jinja html templates
Diffstat (limited to 'app/static/block_weather.js')
| -rw-r--r-- | app/static/block_weather.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/static/block_weather.js b/app/static/block_weather.js new file mode 100644 index 0000000..4ae6d2d --- /dev/null +++ b/app/static/block_weather.js @@ -0,0 +1,14 @@ +export function updateWeather() { + const city = document.getElementById("city").value; + fetch(`/weather?city=${encodeURIComponent(city)}`) + .then(res => res.json()) + .then(data => { + if (!data) { + document.getElementById("weather-summary").innerText = `Error, "${city}" city not found`; + return + } + document.getElementById("weather-summary").innerText = data.summary; + document.getElementById("weather-icon").src = data.icon_url; + }); +} + |
