From f6890ed3234a205c28a8ac9fe0a7d1ddc3fe2b76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 4 Jul 2023 19:18:27 +0200 Subject: [PATCH] Continued: - if response is not okay, throw exception - avoids init of domain_data variable --- daemon.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/daemon.py b/daemon.py index 89b288f..2f2e328 100755 --- a/daemon.py +++ b/daemon.py @@ -342,9 +342,10 @@ def rss(request: Request, domain: str): response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/domain.json?domain={domain}") - domain_data = dict() - if response is not None and response.ok: - domain_data = response.json() + if not response.ok or response.status_code > 200 or response.text.strip() == "": + raise HTTPException(status_code=response.status_code, detail=response.reason) + + domain_data = response.json() # Format timestamps format = config.get("timestamp_format") -- 2.39.5