diff --git a/pkgs/clan-cli/clan_cli/webui/routers/root.py b/pkgs/clan-cli/clan_cli/webui/routers/root.py index 77f460e08..550c6851a 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/root.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/root.py @@ -30,6 +30,8 @@ async def root(path_name: str) -> Response: if not filename.is_file(): log.error("File not found: %s", filename) return Response(status_code=404) + else: + return Response(status_code=404) content_type, _ = guess_type(filename) return Response(filename.read_bytes(), media_type=content_type) diff --git a/pkgs/clan-cli/tests/test_static_files.py b/pkgs/clan-cli/tests/test_static_files.py new file mode 100644 index 000000000..4db1e3aa2 --- /dev/null +++ b/pkgs/clan-cli/tests/test_static_files.py @@ -0,0 +1,10 @@ +import pytest +from api import TestClient + + +@pytest.mark.impure +def test_static_files(api: TestClient) -> None: + response = api.get("/") + assert response.headers["content-type"] == "text/html; charset=utf-8" + response = api.get("/does-no-exists.txt") + assert response.status_code == 404