Add website favicon support

This commit is contained in:
Dymas
2026-07-09 18:15:52 +02:00
parent 34c77ed9bb
commit ba408877b5
10 changed files with 35 additions and 2 deletions
+9
View File
@@ -27,6 +27,7 @@ from app_support import (
CLIENT_DISCONNECT_ERRORS,
MAX_JSON_BODY_BYTES,
MODE_CHOICES,
PROJECT_ROOT,
VERSION,
client_address_is_local,
configured_remote_path_roots,
@@ -46,6 +47,8 @@ from app_support import (
validate_discord_webhook_url,
)
FAVICON_PATH = PROJECT_ROOT / "favicon.png"
@dataclass(frozen=True)
class HandlerContext:
add_to_watchlist: object
@@ -382,6 +385,7 @@ class Handler(BaseHTTPRequestHandler):
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{APP_NAME} sign in</title>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png">
<style>
:root {{
color-scheme: dark;
@@ -545,6 +549,11 @@ class Handler(BaseHTTPRequestHandler):
self.ensure_client_access()
if parsed.path == "/":
self.html(Handler._context(self).index_html)
elif parsed.path in {"/favicon.png", "/favicon.ico"}:
if not FAVICON_PATH.exists():
self.error(HTTPStatus.NOT_FOUND, "Favicon not found")
return
self.file(FAVICON_PATH)
elif parsed.path == "/queue":
self.html(Handler._context(self).queue_html)
elif parsed.path == "/config":