kopia lustrzana https://github.com/simonw/datasette
New, improved favicon - refs #1603
rodzic
e1770766ce
commit
0467723ee5
|
@ -70,6 +70,7 @@ from .utils.asgi import (
|
||||||
Response,
|
Response,
|
||||||
asgi_static,
|
asgi_static,
|
||||||
asgi_send,
|
asgi_send,
|
||||||
|
asgi_send_file,
|
||||||
asgi_send_html,
|
asgi_send_html,
|
||||||
asgi_send_json,
|
asgi_send_json,
|
||||||
asgi_send_redirect,
|
asgi_send_redirect,
|
||||||
|
@ -178,9 +179,17 @@ SETTINGS = (
|
||||||
|
|
||||||
DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS}
|
DEFAULT_SETTINGS = {option.name: option.default for option in SETTINGS}
|
||||||
|
|
||||||
|
FAVICON_PATH = app_root / "datasette" / "static" / "favicon.png"
|
||||||
|
|
||||||
|
|
||||||
async def favicon(request, send):
|
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:
|
class Datasette:
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 1.2 KiB |
|
@ -63,7 +63,9 @@ def test_homepage_options(app_client):
|
||||||
def test_favicon(app_client):
|
def test_favicon(app_client):
|
||||||
response = app_client.get("/favicon.ico")
|
response = app_client.get("/favicon.ico")
|
||||||
assert response.status == 200
|
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):
|
def test_static(app_client):
|
||||||
|
|
Ładowanie…
Reference in New Issue