3 changed files with 36 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||
|
code . |
||||
|
python -m venv .venv |
||||
|
.venv\scripts\activate |
||||
|
pip install requests termcolor colorama |
||||
|
pip freeze > 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 |
||||
@ -0,0 +1,24 @@ |
|||||
|
import requests |
||||
|
import json |
||||
|
#Klíč získate na https://home.openweathermap.org/api_keys |
||||
|
KLIC = "<API_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}") |
||||
Loading…
Reference in new issue