parent
19d7f17310
commit
b9618e57c5
@ -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)
|
||||
|
10
pkgs/clan-cli/tests/test_static_files.py
Normal file
10
pkgs/clan-cli/tests/test_static_files.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user