mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Cleaned up favicon()
This commit is contained in:
parent
28c31b228d
commit
620f0aa4f8
2 changed files with 5 additions and 10 deletions
|
|
@ -36,6 +36,7 @@ from .utils import (
|
|||
from .utils.asgi import (
|
||||
AsgiLifespan,
|
||||
asgi_static,
|
||||
asgi_send,
|
||||
asgi_send_html,
|
||||
asgi_send_json,
|
||||
asgi_send_redirect,
|
||||
|
|
@ -131,14 +132,7 @@ DEFAULT_CONFIG = {option.name: option.default for option in CONFIG_OPTIONS}
|
|||
|
||||
|
||||
async def favicon(scope, receive, send):
|
||||
await send(
|
||||
{
|
||||
"type": "http.response.start",
|
||||
"status": 200,
|
||||
"headers": [[b"content-type", b"text/plain"]],
|
||||
}
|
||||
)
|
||||
await send({"type": "http.response.body", "body": b""})
|
||||
await asgi_send(send, "", 200)
|
||||
|
||||
|
||||
class Datasette:
|
||||
|
|
|
|||
|
|
@ -213,12 +213,13 @@ async def asgi_send_redirect(send, location, status=302):
|
|||
)
|
||||
|
||||
|
||||
async def asgi_send(send, content, status, headers, content_type="text/plain"):
|
||||
async def asgi_send(send, content, status, headers=None, content_type="text/plain"):
|
||||
await asgi_start(send, status, headers, content_type)
|
||||
await send({"type": "http.response.body", "body": content.encode("utf8")})
|
||||
|
||||
|
||||
async def asgi_start(send, status, headers, content_type="text/plain"):
|
||||
async def asgi_start(send, status, headers=None, content_type="text/plain"):
|
||||
headers = headers or {}
|
||||
# Remove any existing content-type header
|
||||
headers = dict([(k, v) for k, v in headers.items() if k.lower() != "content-type"])
|
||||
headers["content-type"] = content_type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue