From 0ccbb18411e8dfbd071a091c0298855620c5550f Mon Sep 17 00:00:00 2001 From: moanos Date: Tue, 5 Nov 2024 07:37:52 +0100 Subject: [PATCH] feat: Add function to check if site is up --- src/fellchensammlung/tools/misc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/fellchensammlung/tools/misc.py b/src/fellchensammlung/tools/misc.py index 6c94b47..6eb9fdd 100644 --- a/src/fellchensammlung/tools/misc.py +++ b/src/fellchensammlung/tools/misc.py @@ -34,3 +34,11 @@ def healthcheck_ok(): requests.get(settings.HEALTHCHECKS_URL, timeout=10) except requests.RequestException as e: logging.error("Ping to healthcheck-server failed: %s" % e) + + +def is_404(url): + try: + result = requests.get(url, timeout=10) + return result.status_code == 404 + except requests.RequestException as e: + logging.warning(f"Request to {url} failed: {e}")