update shell.nix; add route for style.css

This commit is contained in:
gnat 2024-08-27 20:49:55 -07:00
parent e98321e832
commit cffcbcaa34
2 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,7 @@ pkgs.mkShell {
pkgs.python312Packages.beautifulsoup4 pkgs.python312Packages.beautifulsoup4
pkgs.python312Packages.pygraphviz pkgs.python312Packages.pygraphviz
pkgs.python312Packages.requests_toolbelt pkgs.python312Packages.requests_toolbelt
pkgs.python312Packages.pyaml
]; ];
shellHook = '' shellHook = ''
python src/main.py python src/main.py

View File

@ -30,7 +30,7 @@ class Route:
return response return response
except Exception as e: except Exception as e:
log.error(tracebark.format_exc) log.error(traceback.format_exc)
return error_page(500) return error_page(500)
def matches(self, request: 'Request') -> bool: def matches(self, request: 'Request') -> bool:
@ -38,6 +38,14 @@ class Route:
return self.matcher(request.path) return self.matcher(request.path)
routes = [ routes = [
Route(
lambda request: request.path == '/style.css',
[Method.GET],
lambda request, *_: Response(
ResponseCode.OK,
*raw_file_contents('./style.css')
)
),
Route( Route(
lambda request: request.path == '/', lambda request: request.path == '/',
[Method.GET, Method.POST], [Method.GET, Method.POST],