Public
Weather data → AI-generated art via Open-Meteo + Replicate
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Fetches real-time weather data and generates AI art that visualizes current conditions.
Rendering mermaid diagram...
- Weather — Fetches current conditions from Open-Meteo (free, no key needed)
- Prompt — Converts temperature, wind, clouds, precipitation, and time-of-day into a vivid scene description
- Image — Sends the prompt to Replicate (Stable Diffusion XL) to generate art
- Response — Returns the image URL as JSON or a rendered HTML page
- Get a Replicate API token at https://replicate.com/account/api-tokens
- Add it as an environment variable:
REPLICATE_API_TOKEN
Endpoint: GET /
| Param | Default | Description |
|---|---|---|
lat | 40.7128 | Latitude |
lon | -74.006 | Longitude |
location | New York | Location name (used in prompt) |
format | json | json or html |
# JSON response (default)
GET /?location=Tokyo&lat=35.6762&lon=139.6503
# HTML page with rendered image
GET /?location=Paris&lat=48.8566&lon=2.3522&format=html
cron.ts runs on a schedule (configure in Val Town UI) and stores the latest result in blob storage under the key weather-art-latest.
main.ts— HTTP handler (entrypoint)cron.ts— Interval/cron handlershared/weather.ts— Open-Meteo API clientshared/prompt.ts— Weather → image prompt buildershared/replicate.ts— Replicate SDXL client