Skip to main content
This lesson walks through creating a lightweight Flask web application that fetches and decodes METAR weather reports into plain English. The result: a small web form where a user types an ICAO airport code (e.g., KJFK, KLAX) and receives a human-friendly weather summary plus the raw METAR. Keywords: Flask METAR reader, METAR decoder, aviationweather.gov, ICAO, NOAA ADDS.

What is a METAR?

METAR is the international (ICAO) standard format for aviation weather observations. The encoded lines can look cryptic to non-pilots but contain a compact, consistent representation of winds, visibility, clouds, temperature, pressure, and weather phenomena. Our app uses a public METAR API and decodes each field into readable phrases.
A screenshot of a web browser open to the Wikipedia article for "METAR,"
showing the article text and contents list on the left with a small photo and
appearance settings on the right. The browser window includes tabs and a dark
desktop
background.
Example raw METAR (compact / cryptic):
KJFK 052151Z 16008KT 10SM SCT047 SCT210 BKN250 24/21 A3031 RMK AO2 SLP262 T02440206
A decoded app should present that as human-readable lines like:
  • Winds 160° at 8 knots
  • Visibility 10 statute miles
  • Scattered clouds at 4,700 ft and 21,000 ft; broken at 25,000 ft
  • Temperature 24°C / Dew point 21°C
  • Altimeter 30.31 inHg

METAR components quick reference

ComponentWhat it meansExample from KJFK
Station IDICAO airport codeKJFK
TimeTimestamp of observation (DDHHMMZ)052151Z
WindDirection and speed16008KT
VisibilityPrevailing visibility, usually in statute miles10SM
Cloud groupsCLR, FEW, SCT, BKN, OVC + height (hundreds of feet)SCT047 SCT210 BKN250
Temp/Dew pointTemperature and dew point in °C24/21
AltimeterPressure (inHg)A3031
Remarks/PhenomenaRMK, weather codes like RA, FG, TSRA = rain, FG = fog

Project plan and goals

  • Build a Flask web app with:
    • An input form for ICAO codes (index page)
    • A results template showing parsed summary + raw METAR
    • Basic, responsive styling (static/style.css)
  • Use a public METAR data source (NOAA/ADDS or aviationweather.gov)
  • Implement a METAR decoder that:
    • Extracts winds, visibility, cloud layers, temperatures, altimeter, observation time, and weather phenomena
    • Converts wind degrees to compass headings and reports calm conditions
    • Converts units where helpful (°C ↔ °F, inHg)
  • Include basic error handling: invalid ICAO, no data, network errors
  • Provide a reproducible local workflow using a virtual environment

Example CLI: starting Claude Code For Beginners

A typical interactive session starting Claude Code (example):
jeremy@MACSTUDIO KodeKloud-METAR-Reader % claude

Do you trust the files in this folder?
/Users/jeremy/Repos/KodeKloud-METAR-Reader

Claude Code may read files in this folder. Reading untrusted files may lead Claude Code to behave in unexpected ways.

With your permission Claude Code may execute files in this folder. Executing untrusted code is unsafe.

https://docs.anthropic.com/s/claude-code-security

> 1. Yes, proceed
  2. No, exit

Enter to confirm · Esc to exit
Example condensed prompt sent to Claude Code For Beginners:
Create a FLASK web application. This application will be a "METAR Reader". The user can type in an airport code, and then the application will fetch the METAR reading from that airport, and decode it. METAR is a standardized weather report. It is somewhat cryptic so I would like to convert it into plain English that people can understand. For instance, "Clear day, 70 degrees, wind 5mph to the south". This app will be successful if people can type in an airport code, and receive a friendly readable weather report. Use an aviation weather API (for example NOAA/ADDS METAR service, e.g. https://aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&stationString=KHIO&format=xml) as a reference.

What Claude generated and common tasks

Claude helped scaffold the project and suggested a todo list and file structure. Typical outputs and tasks include:
  • Files generated
    • app.py — Flask application and route handlers
    • metar_decoder.py — parsing and conversion helpers (wind, clouds, visibility, etc.)
    • templates/index.html — search form
    • templates/result.html — decoded results and raw METAR
    • static/style.css — basic styling
    • requirements.txt — Python dependencies
Example requirements.txt produced:
Flask==2.3.3
requests==2.31.0
Common coding tasks to implement:
  • Fetch METAR data from aviationweather.gov or NOAA ADDS endpoints
  • Implement a robust METAR decoder to parse:
    • Wind: “16008KT” → 160° at 8 knots; detect “00000KT” (calm)
    • Visibility: e.g., “10SM” → 10 statute miles or “1/2SM”
    • Clouds: convert “SCT047” to “scattered at 4,700 ft”; handle CLR/SKC
    • Temperature/dew: parse “24/21” and produce °C and approximate °F
    • Altimeter: “A3031” → 30.31 inHg
    • Phenomena codes: RA (rain), SN (snow), FG (fog), BR (mist), TS (thunderstorm), SH (showers)
  • Create Jinja templates to display both the friendly summary and the raw METAR string
  • Add unit tests for the decoder functions

Project scaffolding (example commands)

  • Create project layout:
    • mkdir -p metar_reader/{templates,static}
    • touch app.py metar_decoder.py requirements.txt
  • Virtual environment and install:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Running the app locally

After installing dependencies in a virtual environment:
source venv/bin/activate
python app.py
Flask development server defaults to: Note: Ensure the venv is activated in the same shell where you run python so the installed packages are available.
Run: python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt. Then start the app with python app.py and open http://127.0.0.1:5000 in your browser.

Testing in the browser — KHIO example

Try KHIO (Hillsboro, OR) in the web form. The app fetches the METAR and displays a readable weather card. Example decoded output shown by the app:
  • Clear skies, 27°C (≈81°F)
  • Wind: 000° at 0 knots (calm)
  • Visibility: 10+ statute miles
  • Altimeter: 30.05 inHg
  • Observation time: timestamp from the METAR
Raw METAR:
KHIO 052253Z 00000KT 10SM CLR 27/11 A3005 RMK AO2 SLP172 T02670106
A browser window showing a "Weather Report for KHIO" with current conditions
(clear skies, 81°F / 27°C, wind from the north at 0 knots) and a detailed
table of observation data. The report is centered on a purple gradient
background.

Testing in the browser — KLAX example

Enter KLAX (Los Angeles) to verify cloud layers, winds, and other fields are parsed and presented cleanly. Raw METAR:
KLAX 052253Z 26011KT 10SM FEW250 24/17 A2996 RMK AO2 SLP145 T02390172
Decoded example:
  • Few clouds at ~25,000 ft
  • Temperature 24°C (≈75°F), dew point 17°C
  • Wind 260° at 11 knots
  • Visibility 10 statute miles
A browser screenshot of a "Weather Report for KLAX" webpage showing current
conditions (few clouds at 25,000 ft, 75°F / 24°C, wind from the west at 11
knots) and a detailed information table below. The page is displayed on a
purple gradient background with a white card in the
center.

Next steps and extensions

This project is a useful base for further improvements:
  • Add unit tests for the METAR decoder (pytest)
  • Improve UI/UX and accessibility (ARIA, keyboard nav)
  • Harden error handling (API rate limits, retries, invalid ICAO codes)
  • Cache or store historical METARs for trend displays
  • Extend to other aviation products (TAFs, SIGMETs) or integrate with mapping libraries
Thanks for following this lesson — use this METAR reader as a foundation to explore more automated coding workflows and to build reliable, testable utilities around real-world aviation data.

Watch Video