awx

← Blog

Walk-through · 13 November 2026

How to turn a weather API into a web page that stays up

You found a weather API that answers with JSON. You want a web page that shows the latest weather, and an address you can send to anyone. This walk-through does both on an awx computer. Every screenshot is from a real computer.

What we are building

One HTML file. It asks the weather service for the current weather in a city, shows the temperature, how it feels, the humidity and the wind, and lists the next five days. A drop-down switches city. It works on a phone, and it refreshes itself every ten minutes.

The page runs in the visitor's browser, so there is no PHP, no database and nothing to install on the computer. The computer only has to hand out the file, and that is what keeps the address alive.

https://myweather.awanbox.com/
A weather page for Kuala Lumpur showing 27 degrees, cloudy, with feels like, humidity and wind boxes and a five day forecast
The finished page. The data is whatever the weather service says right now.

Or ask the agent to build it

You do not have to write the page yourself. awx has a chat, and the agent in it works on a computer of its own. Here is the whole thing, start to finish.

1. Start a chat. On the Workbench page press New chat and pick a size. A new computer is made for the chat, and it keeps its files when it goes to sleep.

The New chat dialog with two choices: on a new computer, with the sizes Small and Large and their price per hour, or on a computer you already have
A small computer is plenty for a page like this.

2. Say what you want. Paste the address of the API and describe the page in plain words. For example:

Here is a weather API that returns JSON: https://api.open-meteo.com/v1/forecast?latitude=3.14&longitude=101.69&current=temperature_2m,relative_humidity_2m,wind_speed_10m,weather_code&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=5 . Make a web page that shows the current temperature, humidity and wind, and the next five days, with a drop-down to pick a city. Serve it on port 8000.

The chat page with the weather request typed into the message box and a Send button
The request is typed in. Press Send.

3. Watch it work. The agent looks at the JSON, writes index.html, starts a web server and checks that the page loads. Each step shows in the chat, and you can open output under a step to see what came back. Before it makes a public link it stops and asks you, because anyone who has the link can open the page.

The chat showing the agent's steps and a yellow box saying The agent asks: Publish port 8000 as a public link, with Approve and Decline buttons
It waits for your answer. You can close the page and come back; it keeps waiting.

4. Approve. The agent makes the link and says what it did, including what is still left for you.

The chat after approval, with the agent's closing message about the weather page, the link under Previews and keeping the server running
The agent's last message.

5. Open the link. The new link is listed under Previews, in Active links, with its address, its port and when it expires.

The Active links table with one link on port 8000, its address, a Copy button and the expiry
The link, listed under Previews.

Two things stay yours. The agent makes the temporary kind of link, so the permanent name is still step 7 below. And a program the agent starts by hand is not looked after by awx, so add the server under Services (step 8) to keep it running. Either way you can read the whole run afterwards and open the files it wrote, so you still learn how the page works.

A note on what you see: the agent's wording and its steps can differ from these screenshots. A model may explain things its own way or take another route to the same page.

The steps below do the same thing by hand. Read them once, and you will know what to ask for and how to fix it when the agent gets something wrong.

1. Make a computer

On the Computers page press New computer, give it a name such as myweather, and pick the smallest size. A page that only serves one file needs very little. It is usually ready in a few seconds.

The New computer form with the name myweather typed in and the Small size picked, at RM0.03 an hour
The New computer form with Small picked, at RM0.03 an hour. Press Create.

2. Look at the JSON first

Before you write any page, look at what the API really sends. Open the computer's Terminal tab and ask for it. This example uses Open-Meteo, a free weather service that needs no account and no key. Your API will have its own address, but the idea is the same.

curl -s 'https://api.open-meteo.com/v1/forecast?latitude=3.14&longitude=101.69&current=temperature_2m,relative_humidity_2m,weather_code' | python3 -m json.tool

The python3 -m json.tool part only prints the answer with line breaks so that you can read it.

The terminal tab after running the curl command, showing the JSON answer with latitude, longitude, timezone and a current block
The answer is plain JSON: names with values, and a block called current.

Read it like a form. The values you want sit inside current: the temperature, the humidity and a weather_code. Write down their names exactly, because the page has to use the same ones. Here is just the part we need, shortened:

{
    "latitude": 3.1282952,
    "longitude": 101.68548,
    "current_units": { "temperature_2m": "°C", "relative_humidity_2m": "%" },
    "current": {
        "time": "2026-11-13T11:15",
        "temperature_2m": 26.7,
        "relative_humidity_2m": 92,
        "weather_code": 3
    }
}

The weather_code is a number, not words. Open-Meteo uses the WMO list: 0 is clear sky, 3 is cloudy, 63 is rain, 95 is a thunderstorm. Your page will turn the number into words and a small picture.

3. Read it in JavaScript

The browser has fetch for asking a web address for data, and it can turn the JSON answer into an object you can pick values from. This is the whole idea in four lines:

const url = "https://api.open-meteo.com/v1/forecast?latitude=3.14&longitude=101.69" +
  "&current=temperature_2m,relative_humidity_2m,weather_code";

const response = await fetch(url);
const data = await response.json();

console.log(data.current.temperature_2m);   // 26.7

After response.json(), the JSON is an object. A value inside is reached with dots: data.current.temperature_2m. A list, such as the five days, is reached with a number: data.daily.time[0] is today.

One thing to know. A browser only lets a page read data from another website if that website allows it. Open-Meteo does, so the page can ask it directly. If your API does not allow it, you will see a CORS error in the browser console, and the fix is to ask the API from a small program on the computer instead of from the page.

4. Write the page

The page has three parts. The HTML is a place to put the answer. The JavaScript asks the service, picks out the values and fills that place. The CSS makes it look like something you would show to someone. The full file is below, about ninety lines, if you want to copy it.

Three things in it are worth a look. The list of cities holds a name and a pair of numbers for each, and the drop-down is made from that list, so adding a city is one line. The codes table turns a weather code into words and a picture. And the last line asks again every ten minutes, because the service only updates about every fifteen.

The whole file, index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My weather</title>
  <style>
    body { margin: 0; font: 18px/1.5 system-ui, sans-serif; background: #e8f1fb; color: #16202e; }
    main { max-width: 560px; margin: 0 auto; padding: 1.6rem 1.2rem 2.4rem; }
    h1 { margin: 0 0 .8rem; font-size: 1.1rem; font-weight: 600; color: #46566b; }
    select { font: inherit; padding: .35rem .6rem; border-radius: 8px; border: 1px solid #b8c7da; background: #fff; }
    .now { display: flex; align-items: center; gap: 1rem; background: #fff; border-radius: 16px; padding: 1.2rem 1.4rem; margin: 1rem 0; box-shadow: 0 1px 3px rgba(22, 32, 46, .12); }
    .icon { font-size: 4rem; line-height: 1; }
    .temp { font-size: 3.4rem; font-weight: 700; line-height: 1; }
    .what { color: #46566b; margin-top: .3rem; }
    .facts { display: flex; gap: .8rem; margin-bottom: 1rem; }
    .facts div { flex: 1; background: #fff; border-radius: 12px; padding: .7rem .9rem; font-size: .92rem; color: #46566b; box-shadow: 0 1px 3px rgba(22, 32, 46, .12); }
    .facts b { display: block; font-size: 1.15rem; color: #16202e; }
    .days { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
    .day { background: #fff; border-radius: 12px; padding: .6rem .3rem; text-align: center; font-size: .86rem; color: #46566b; box-shadow: 0 1px 3px rgba(22, 32, 46, .12); }
    .day span { display: block; font-size: 1.6rem; }
    .day b { color: #16202e; }
    .updated { margin-top: 1rem; font-size: .85rem; color: #6b7b90; }
    .error { background: #fde8e8; color: #8a1f1f; padding: .8rem 1rem; border-radius: 10px; }
  </style>
</head>
<body>
<main>
  <h1>Weather in <select id="city"></select></h1>
  <div id="out">Loading…</div>
  <p class="updated" id="updated"></p>
</main>
<script>
  const cities = {
    "Kuala Lumpur": [3.14, 101.69],
    "Kuala Terengganu": [5.33, 103.14],
    "Kuching": [1.55, 110.34],
    "Penang": [5.41, 100.33]
  };
  // WMO weather codes, as the API sends them
  const codes = {
    0: ["Clear sky", "☀️"], 1: ["Mostly clear", "🌤️"], 2: ["Partly cloudy", "⛅"], 3: ["Cloudy", "☁️"],
    45: ["Fog", "🌫️"], 48: ["Fog", "🌫️"], 51: ["Light drizzle", "🌦️"], 53: ["Drizzle", "🌦️"], 55: ["Heavy drizzle", "🌧️"],
    61: ["Light rain", "🌦️"], 63: ["Rain", "🌧️"], 65: ["Heavy rain", "🌧️"], 80: ["Showers", "🌦️"], 81: ["Showers", "🌧️"],
    82: ["Heavy showers", "🌧️"], 95: ["Thunderstorm", "⛈️"], 96: ["Thunderstorm", "⛈️"], 99: ["Thunderstorm", "⛈️"]
  };
  const look = c => codes[c] || ["Unknown", "🌡️"];

  const select = document.getElementById("city");
  for (const name in cities) select.add(new Option(name));
  select.value = localStorage.getItem("city") || "Kuala Lumpur";

  async function load() {
    const [lat, lon] = cities[select.value];
    const url = "https://api.open-meteo.com/v1/forecast?latitude=" + lat + "&longitude=" + lon +
      "&current=temperature_2m,apparent_temperature,relative_humidity_2m,wind_speed_10m,weather_code" +
      "&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=5";
    const out = document.getElementById("out");
    try {
      const r = await fetch(url);
      if (!r.ok) throw new Error("The weather service answered " + r.status);
      const d = await r.json();
      const [text, icon] = look(d.current.weather_code);
      out.innerHTML =
        '<div class="now"><div class="icon">' + icon + '</div><div><div class="temp">' + Math.round(d.current.temperature_2m) +
        '°C</div><div class="what">' + text + '</div></div></div>' +
        '<div class="facts"><div>Feels like<b>' + Math.round(d.current.apparent_temperature) + '°C</b></div>' +
        '<div>Humidity<b>' + d.current.relative_humidity_2m + '%</b></div>' +
        '<div>Wind<b>' + d.current.wind_speed_10m + ' km/h</b></div></div>' +
        '<div class="days">' + d.daily.time.map((t, i) => {
          const day = new Date(t).toLocaleDateString("en-GB", { weekday: "short" });
          return '<div class="day">' + day + '<span>' + look(d.daily.weather_code[i])[1] + '</span><b>' +
            Math.round(d.daily.temperature_2m_max[i]) + '°</b> ' + Math.round(d.daily.temperature_2m_min[i]) + '°</div>';
        }).join("") + '</div>';
      document.getElementById("updated").textContent = "Updated " + new Date().toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
    } catch (e) {
      out.innerHTML = '<div class="error">Could not load the weather. ' + e.message + '</div>';
    }
  }

  select.addEventListener("change", () => { localStorage.setItem("city", select.value); load(); });
  load();
  setInterval(load, 10 * 60 * 1000); // refresh every ten minutes
</script>
</body>
</html>

Open the Files tab, make a folder called weather under /home/agent, and put the file in it as index.html. You can paste the text into the editor there, or upload the file from your own laptop.

The Files tab showing the folder home agent weather with index.html in it
The folder with the page in it.

5. Run it

Python is already on the computer, and it can hand out files from a folder. In the terminal:

cd /home/agent/weather
python3 -m http.server 8000

That is a small web server on port 8000 of the computer. Leave it running for now, and look at the result in the next step. When you are happy, press Ctrl+C and we will make it run on its own in step 8.

Open the Previews tab, type 8000 as the port, and press Share. You get an address that anyone can open, without an account. Copy it from the box. You can find it again later under Active links.

The Your link dialog showing a long random web address and Copy and Done buttons
Anyone who has the link can open your page until it expires.

A new link lasts from one hour up to seven days. That is right for showing a friend, and wrong for something you want to keep. For that, give the page a name.

7. Give it a name

Under Custom names pick a short name and the port. The name myweather with port 8000 gives you myweather.awanbox.com. It does not expire. It works until you remove it, and it works while the computer is on. You can have three names, and names that look like part of awx itself, such as www or admin, are refused.

The Custom names card with a list showing myweather.awanbox.com on port 8000 and a Remove button
A name that is yours, for as long as you want it.

Back in Active links, the table now shows this name in the Link column instead of the long random address, because it is the one you will give to people.

The Active links table with myweather.awanbox.com in the Link column, marked custom name, with a Copy button
With a custom name, the Link column shows it.

Open the address on your phone to check it. The page is built to fit a small screen.

The weather page on a phone, with the temperature, the facts and the five day forecast stacked in one column
The same page on a phone.

8. Keep it up

Two things can make the address stop answering: the web server program stopping, and the computer going to sleep. Both have a setting.

The server. Under Services add one called web. The command is python3 -m http.server 8000, the folder is /home/agent/weather, and the port is 8000. Tick Keep this computer awake, which marks the service always on. awx starts it whenever the computer starts, and starts it again a few seconds after a crash. Stop the one you ran by hand first, or the two will fight over port 8000.

The Services card with a service called web marked always on, the command python3 -m http.server 8000, port 8000, and the state running
The server, now managed by awx. The mark next to its name says always on.

Sleep. An awx computer goes to sleep after 30 minutes without activity, and a visit to your address counts as activity. A quiet page at three in the morning does not. Under Settings, Power, tick Keep it running until my credit runs out (on the paid plan it reads Never stop it for being idle) and the computer stays on until you stop it or your credit is gone. More in why a computer sleeps, and how to keep it running.

The Power card in Settings with the switch Keep it running until my credit runs out ticked
Tick it, and the address keeps answering. On the Free plan it uses credit every hour.

If you ever stop the computer, start it from the Computers page. The server comes back with it, and the same address works again.

9. Change it later

Because the page is only a file, a change is two moves: edit index.html in the Files tab, and refresh the browser. There is nothing to restart. Try adding your own town to the list of cities, or choose another city in the drop-down.

https://myweather.awanbox.com/
The same weather page now showing Kuching, with a different temperature and forecast
Pick another city and the page asks the service again.

A note on API keys

This API needs no key, which is why the page can ask for the data itself. Many weather services give you a key instead. Do not put a key in an HTML page: anyone who opens the page can read it with one click, and they can use your allowance. Keep the key in a small program on the computer, and let the page ask that program. awx can run it as a second service, the same way as the web server.

Also read the terms of the service you use. Free ones often limit how many requests you can make, and some do not allow use in a business.

A note on limits

The address works while the computer is on. On the Free plan a computer that stays on uses credit every hour (Small is RM0.03 an hour, about RM22 a month). The paid plan runs for free.

New to awx? Why we think you can leave XAMPP behind is the short version, Put your PHP and MySQL assignment online does the same for a page with a database, and awx accounts are approved by hand for now, so sign in with Google and confirm your email first.

Keep reading

Awi the cat agent waves hello

Awi, signing off.

← All posts