Pinned 2026 toolchains (Go 1.26, Rust 1.98/edition 2024, Python 3.14 + uv, Node 24, Zig 0.16, NixOS 26.05), postgres 18 / mongo 8, lockfiles built from, non-root runtimes, .dockerignore, per-project LICENSE, READMEs with the git.devai.io clone line, checkout@v7 CI. Security fixes in the legacy Rust APIs (any-password login, self-assigned admin, hard-coded JWT secret), JWT alg/exp/sub enforcement across the blog series, safe markdown links in the frontends, and many smaller bugs — every project was built, run and exercised end to end. Adds scripts/publish.sh + a CI publish job that splits every folder into its own repo at git.devai.io/templates/<folder>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01128fhuZbgivaSJvtMf4s1G
2.2 KiB
weather-now
Type any city and see its temperature, sky, humidity and wind right now, from the free Open-Meteo APIs. It teaches chaining two API calls: the answer to the first becomes the question for the second.
Run
Get it: git clone https://git.devai.io/templates/weather-now.git
Double-click index.html — it opens in your browser and works, as long as
you're online (it calls the weather service live). Nothing to install.
Or serve it like production:
docker compose up --build
Then open http://localhost:8080.
How it works
Weather is looked up by coordinates, not city names, so loadWeather(city)
makes two requests, one after the other:
- Geocode —
geocoding-api.open-meteo.com/v1/search?name=Tokyoanswers with the best match'slatitudeandlongitude. - Forecast — those numbers go into
api.open-meteo.com/v1/forecast?latitude=…&longitude=…¤t=…, which answers with the current temperature, humidity, wind and aweather_code.
await makes the second call wait for the first. The weather code is a WMO
number (0 = clear, 61 = light rain, …); WEATHER_CODES maps the common
ones to words and an emoji. encodeURIComponent keeps spaces and accents in a
city name from breaking the URL. Both APIs are free and need no key.
"Loading…" shows while the requests run, "City not found." when geocoding has no match, and a friendly error if either call fails.
Try it: add &temperature_unit=fahrenheit to the forecast URL, ask for
count=5 and let the user pick between matches, or add more weather codes.
Layout
index.html the search form, a status line and a hidden weather card
app.js the code table, loadWeather() and render()
styles.css the look; follows your system's light or dark mode
Deploy
Push to your own GitHub repo and the shipped workflow
(.github/workflows/ci.yml) tests the compose stack, publishes the image to
GHCR, and — once you set the DEPLOY_HOST / DEPLOY_USER variables and
DEPLOY_KEY secret — deploys it to your server over ssh.
Part of devai.io — the APIs & Data track: fetch real data from the internet. Next up: github-profile.