Compare commits
No commits in common. "02782a6ce3b241c4d024c06aad6d6eb8dc6df597" and "357baf0b5737d809cfcdce408c6f66e9738b92d5" have entirely different histories.
02782a6ce3
...
357baf0b57
@ -13,38 +13,31 @@ base_url = "https://api.openweathermap.org/data/2.5/weather?"
|
||||
complete_url = base_url + "appid=" + api_key + "&q=" + city_name
|
||||
response = requests.get(complete_url)
|
||||
|
||||
data = response.json()
|
||||
x = response.json()
|
||||
|
||||
print()
|
||||
match response.status_code:
|
||||
case 200:
|
||||
info_main = data["main"]
|
||||
info_weather = data["weather"]
|
||||
current_temperature = info_main["temp"]
|
||||
current_pressure = info_main["pressure"]
|
||||
current_humidity = info_main["humidity"]
|
||||
weather_description = info_weather[0]["description"]
|
||||
if x["cod"] != "404":
|
||||
|
||||
print(Columns([
|
||||
Panel(f"[blue]{round(current_temperature - 273.15, 2)}°C",
|
||||
title="[bold]Temperature"),
|
||||
y = x["main"]
|
||||
current_temperature = y["temp"]
|
||||
current_pressure = y["pressure"]
|
||||
current_humidity = y["humidity"]
|
||||
z = x["weather"]
|
||||
weather_description = z[0]["description"]
|
||||
|
||||
Panel(f"[blue]{current_pressure}hPa",
|
||||
title="[bold]Atmospheric Pressure"),
|
||||
print()
|
||||
print(Columns([
|
||||
Panel(f"[blue]{round(current_temperature - 273.15, 2)}°C",
|
||||
title="[bold]Temperature[/bold]"),
|
||||
|
||||
Panel(f"[blue]{current_humidity}%",
|
||||
title="[bold]Humidity"),
|
||||
|
||||
Panel(f"[blue]{weather_description}",
|
||||
title="[bold]Description"),
|
||||
]))
|
||||
Panel(f"[blue]{current_pressure}hPa",
|
||||
title="[bold]Atmospheric Pressure[/bold]"),
|
||||
|
||||
case _:
|
||||
if "message" in data:
|
||||
print(Panel(data["message"],
|
||||
title=f"[bold red]Error: {response.status_code}",
|
||||
expand=False))
|
||||
else:
|
||||
print(Panel("unknown error",
|
||||
title=f"[bold red]Error: {response.status_code}",
|
||||
expand=False))
|
||||
Panel(f"[blue]{current_humidity}%",
|
||||
title="[bold]Humidity[/bold]"),
|
||||
|
||||
Panel(f"[blue]{weather_description}",
|
||||
title="[bold]Description[/bold]"),
|
||||
]))
|
||||
|
||||
else:
|
||||
print(" City Not Found ")
|
Loading…
x
Reference in New Issue
Block a user