- serve manifest and service worker from the app root for install compatibility - add manifest metadata, service worker registration, and Apple touch icon links to the base template - add install icon assets for Android, iOS, and desktop install flows - document deployment and validation notes for the new PWA support - cover the new endpoints and template output with tests
This commit is contained in:
+17
-1
@@ -1,7 +1,8 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import Depends, FastAPI, File, Form, HTTPException, Request, UploadFile, status
|
||||
from fastapi.responses import RedirectResponse, Response
|
||||
from fastapi.responses import FileResponse, RedirectResponse, Response
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from sqlalchemy import func, or_
|
||||
@@ -12,6 +13,7 @@ from app.images import process_upload
|
||||
from app.models import Box, Item, SubItem
|
||||
|
||||
templates = Jinja2Templates(directory="app/templates")
|
||||
STATIC_DIR = Path("app/static")
|
||||
|
||||
|
||||
def _clean_text(value: str | None) -> str | None:
|
||||
@@ -193,6 +195,20 @@ def create_app() -> FastAPI:
|
||||
def root() -> RedirectResponse:
|
||||
return RedirectResponse(url="/boxes", status_code=status.HTTP_302_FOUND)
|
||||
|
||||
@app.get("/manifest.webmanifest", include_in_schema=False)
|
||||
def manifest() -> FileResponse:
|
||||
return FileResponse(
|
||||
path=STATIC_DIR / "manifest.webmanifest",
|
||||
media_type="application/manifest+json",
|
||||
)
|
||||
|
||||
@app.get("/service-worker.js", include_in_schema=False)
|
||||
def service_worker() -> FileResponse:
|
||||
return FileResponse(
|
||||
path=STATIC_DIR / "service-worker.js",
|
||||
media_type="application/javascript",
|
||||
)
|
||||
|
||||
@app.get("/search")
|
||||
def search_page(
|
||||
request: Request,
|
||||
|
||||
Reference in New Issue
Block a user