diff --git a/pyproject.toml b/pyproject.toml index c7958b9..662a376 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ router-dyndns = "router_dyndns.cli:main" [tool.hatch.build.targets.wheel] packages = ["router_dyndns"] +artifacts = ["router_dyndns/assets/*"] [tool.pytest.ini_options] testpaths = ["tests"] @@ -38,4 +39,3 @@ target-version = "py311" [tool.ruff.lint] select = ["E", "F", "I", "UP", "B"] ignore = ["E501"] - diff --git a/router_dyndns/assets/favicon.ico b/router_dyndns/assets/favicon.ico new file mode 100644 index 0000000..2a758c4 Binary files /dev/null and b/router_dyndns/assets/favicon.ico differ diff --git a/router_dyndns/assets/logo-192.png b/router_dyndns/assets/logo-192.png new file mode 100644 index 0000000..94d05f5 Binary files /dev/null and b/router_dyndns/assets/logo-192.png differ diff --git a/router_dyndns/assets/logo-512.png b/router_dyndns/assets/logo-512.png new file mode 100644 index 0000000..b26a73e Binary files /dev/null and b/router_dyndns/assets/logo-512.png differ diff --git a/router_dyndns/assets/logo.png b/router_dyndns/assets/logo.png new file mode 100644 index 0000000..1985155 Binary files /dev/null and b/router_dyndns/assets/logo.png differ diff --git a/router_dyndns/assets/logo.svg b/router_dyndns/assets/logo.svg new file mode 100644 index 0000000..136e928 --- /dev/null +++ b/router_dyndns/assets/logo.svg @@ -0,0 +1,35 @@ + + router-dyndns logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/router_dyndns/ddns.py b/router_dyndns/ddns.py index 5691217..f567deb 100644 --- a/router_dyndns/ddns.py +++ b/router_dyndns/ddns.py @@ -4,10 +4,11 @@ import html import secrets import sqlite3 import urllib.parse +from pathlib import Path from typing import Annotated from fastapi import Depends, FastAPI, Header, HTTPException, Query, Request, Response -from fastapi.responses import HTMLResponse, PlainTextResponse, RedirectResponse +from fastapi.responses import FileResponse, HTMLResponse, PlainTextResponse, RedirectResponse from starlette.concurrency import run_in_threadpool from .ddns_api import create_api_router @@ -59,6 +60,8 @@ OPENAPI_TAGS = [ }, ] +ASSET_DIR = Path(__file__).with_name("assets") + def make_app(settings: DdnsSettings | None = None) -> FastAPI: settings = settings or DdnsSettings.from_env() @@ -347,8 +350,16 @@ def make_app(settings: DdnsSettings | None = None) -> FastAPI: return "ok" @app.get("/favicon.ico", include_in_schema=False) - def favicon() -> Response: - return Response(status_code=204) + def favicon() -> FileResponse: + return FileResponse(ASSET_DIR / "favicon.ico", media_type="image/x-icon") + + @app.get("/logo.svg", include_in_schema=False) + def logo_svg() -> FileResponse: + return FileResponse(ASSET_DIR / "logo.svg", media_type="image/svg+xml") + + @app.get("/logo.png", include_in_schema=False) + def logo_png() -> FileResponse: + return FileResponse(ASSET_DIR / "logo.png", media_type="image/png") @app.get("/u/{update_slug}", response_class=PlainTextResponse, response_model=None) def slug_update( @@ -608,7 +619,7 @@ def _top_nav(label: str | None = None, show_logout: bool = False, links: str = " return f""" - router-dyndns + router-dyndns {links} {account_html} @@ -962,6 +973,9 @@ def _page(title: str, body: str) -> str: {html.escape(title)} + + +