"""
OpenWeatherMap — Current Weather Demo
======================================
A minimal, ready-to-run example of fetching current weather.

Get an API key (free):
    1. Sign up at https://home.openweathermap.org/users/sign_up
    2. Open the "API keys" tab and copy your key.
    3. Note: a new key can take ~1-2 hours to activate.

Setup:
    pip install requests
    export OPENWEATHER_API_KEY="..."

Run:
    python openweather_demo.py
"""

import os
import requests


def current_weather(city: str) -> dict:
    """Return current weather for a city as a dict."""
    response = requests.get(
        "https://api.openweathermap.org/data/2.5/weather",
        params={
            "q": city,
            "appid": os.environ.get("OPENWEATHER_API_KEY"),
            "units": "metric",
        },
    )
    response.raise_for_status()
    return response.json()


if __name__ == "__main__":
    data = current_weather("Chiang Mai,TH")
    print(f"{data['name']}: {data['main']['temp']}°C, {data['weather'][0]['description']}")
