New, improved favicon - refs #1603

pull/1610/head
Simon Willison 2022-01-19 21:46:03 -08:00
rodzic e1770766ce
commit 0467723ee5
3 zmienionych plików z 13 dodań i 2 usunięć

Wyświetl plik

@ -70,6 +70,7 @@ from .utils.asgi import (
Response,
asgi_static,
asgi_send,
asgi_send_file,
asgi_send_html,
asgi_send_json,
asgi_send_redirect,
@ -178,9 +179,17 @@ SETTINGS = (
DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS}
FAVICON_PATH = app_root / "datasette" / "static" / "favicon.png"
async def favicon(request, send):
await asgi_send(send, "", 200)
await asgi_send_file(
send,
str(FAVICON_PATH),
content_type="image/png",
chunk_size=4096,
headers={"Cache-Control": "max-age=3600, immutable, public"},
)
class Datasette:

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.2 KiB

Wyświetl plik

@ -63,7 +63,9 @@ def test_homepage_options(app_client):
def test_favicon(app_client):
response = app_client.get("/favicon.ico")
assert response.status == 200
assert "" == response.text
assert response.headers["cache-control"] == "max-age=3600, immutable, public"
assert response.headers["content-length"] == "1207"
assert response.headers["content-type"] == "image/png"
def test_static(app_client):