Merge pull request 'webui: pretty urls by also appending .html' (#362) from Mic92-main into main
All checks were successful
checks-impure / test (push) Successful in 8s
checks / test (push) Successful in 1m18s
assets1 / test (push) Successful in 7s

This commit is contained in:
clan-bot 2023-09-28 09:12:43 +00:00
commit 5d09299870

View File

@ -20,9 +20,10 @@ async def root(path_name: str) -> Response:
return Response(status_code=403)
if not filename.is_file():
print(filename)
print(asset_path())
return Response(status_code=404)
if filename.suffix == "":
filename = filename.with_suffix(".html")
if not filename.is_file():
return Response(status_code=404)
content_type, _ = guess_type(filename)
return Response(filename.read_bytes(), media_type=content_type)