From 20a153e857f996e8b6076939e44905ae1a6b3754 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer Date: Fri, 29 Sep 2023 13:29:06 +0200 Subject: [PATCH] Read http status code from response object --- openweather.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openweather.py b/openweather.py index d2e7099..a9a24dc 100755 --- a/openweather.py +++ b/openweather.py @@ -15,7 +15,7 @@ response = requests.get(complete_url) data = response.json() -if data["cod"] != "404": +if response.status_code == 200: info_main = data["main"] info_weather = data["weather"] @@ -40,4 +40,5 @@ if data["cod"] != "404": ])) else: - print(" City Not Found ") + print(f"Fehler: {response.status_code}") + print(response.text)