From cffcbcaa34f20e894b5fc2b2c0ca962486cdc80e Mon Sep 17 00:00:00 2001 From: gnat Date: Tue, 27 Aug 2024 20:49:55 -0700 Subject: [PATCH] update shell.nix; add route for style.css --- shell.nix | 1 + src/lib/router.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index d251118..49322b8 100644 --- a/shell.nix +++ b/shell.nix @@ -10,6 +10,7 @@ pkgs.mkShell { pkgs.python312Packages.beautifulsoup4 pkgs.python312Packages.pygraphviz pkgs.python312Packages.requests_toolbelt + pkgs.python312Packages.pyaml ]; shellHook = '' python src/main.py diff --git a/src/lib/router.py b/src/lib/router.py index 5a9cbcb..706715c 100644 --- a/src/lib/router.py +++ b/src/lib/router.py @@ -30,7 +30,7 @@ class Route: return response except Exception as e: - log.error(tracebark.format_exc) + log.error(traceback.format_exc) return error_page(500) def matches(self, request: 'Request') -> bool: @@ -38,6 +38,14 @@ class Route: return self.matcher(request.path) routes = [ + Route( + lambda request: request.path == '/style.css', + [Method.GET], + lambda request, *_: Response( + ResponseCode.OK, + *raw_file_contents('./style.css') + ) + ), Route( lambda request: request.path == '/', [Method.GET, Method.POST],