diff --git a/24_owmapi/poznamky.txt b/24_owmapi/poznamky.txt new file mode 100644 index 0000000..d8cbe28 --- /dev/null +++ b/24_owmapi/poznamky.txt @@ -0,0 +1,5 @@ +code . +python -m venv .venv +.venv\scripts\activate +pip install requests termcolor colorama +pip freeze > requerements.txt \ No newline at end of file diff --git a/24_owmapi/requerements.txt b/24_owmapi/requerements.txt new file mode 100644 index 0000000..360acee --- /dev/null +++ b/24_owmapi/requerements.txt @@ -0,0 +1,7 @@ +certifi==2026.2.25 +charset-normalizer==3.4.4 +colorama==0.4.6 +idna==3.11 +requests==2.32.5 +termcolor==3.3.0 +urllib3==2.6.3 diff --git a/24_owmapi/rychly_pocasi.py b/24_owmapi/rychly_pocasi.py new file mode 100644 index 0000000..c228262 --- /dev/null +++ b/24_owmapi/rychly_pocasi.py @@ -0,0 +1,24 @@ +import requests +import json +#Klíč získate na https://home.openweathermap.org/api_keys +KLIC = "" +MESTO = input("Zadej město:") + +# & = AltGR+C; {|} = AltGR+B|N +url1 = f"https://api.openweathermap.org/data/2.5/" +url2 = f"weather?q={MESTO}&appid={KLIC}&units=metric" +url = url1+url2 + +print(f"Otevírám stránku: {url}") +odpoved = requests.get(url) +odpoved.raise_for_status() +data = odpoved.json() +print(json.dumps(data,indent=4,ensure_ascii=False)) + +teplota = data["main"]["temp"] +popis = data["weather"][0]["description"] +owm_mesto = data["name"] + +print(f"Město: {owm_mesto} (napsáno:{MESTO})") +print(f"Teplota: {teplota}°C") +print(f"Popis: {popis}") \ No newline at end of file