From 2661e44e78ef9131a1801c2f25a11781618f9060 Mon Sep 17 00:00:00 2001 From: gnat Date: Tue, 22 Oct 2024 03:27:53 -0700 Subject: [PATCH] prevent status.natalieee.net from incrementing visit counter --- src/lib/headers.py | 4 ++-- src/lib/router.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/headers.py b/src/lib/headers.py index cc79ac4..f3b5d8f 100644 --- a/src/lib/headers.py +++ b/src/lib/headers.py @@ -8,11 +8,11 @@ class Headers: def has(self, key: str) -> bool: return key in self.headers.keys() - def get(self, key: str) -> str | None: + def get(self, key: str) -> str: if self.has(key): return self.headers[key] - return None + return '' def add(self, key, value) -> None: self.headers[key] = value diff --git a/src/lib/router.py b/src/lib/router.py index 6c4f40b..09356f9 100644 --- a/src/lib/router.py +++ b/src/lib/router.py @@ -52,7 +52,7 @@ routes = [ lambda request, *_: Response( ResponseCode.OK, {'Content-Type': 'text/html'}, - (parse_file('./home.html', dict(prev='\\/')).encode('utf-8') if request.method == Method.GET else ( + ((parse_file('./home.html', dict(prev='\\/')).encode('utf-8') if not 'Nim httpclient' in request.headers.get('user-agent') else error_page(200)) if request.method == Method.GET else ( [ (lambda form_data: ( (lambda time: (