From c81965326a293f9a67fbc92051a8b12d01f2191a Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Tue, 3 Mar 2026 22:56:54 -0500 Subject: [PATCH] feat: Add Progressive Web App (PWA) support with service worker, manifest, and icons, including associated tests. --- app/factory.py | 17 ++++ app/index.html | 18 ++++ app/main.js | 43 +++++++- app/static/icons/icon-192x192.png | Bin 0 -> 33645 bytes app/static/icons/icon-512x512.png | Bin 0 -> 270434 bytes app/static/manifest.json | 30 ++++++ app/static/sw.js | 160 ++++++++++++++++++++++++++++++ tasks_logs/.metadata_cache.json | 2 +- tests/backend/test_pwa.py | 68 +++++++++++++ 9 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 app/static/icons/icon-192x192.png create mode 100644 app/static/icons/icon-512x512.png create mode 100644 app/static/manifest.json create mode 100644 app/static/sw.js create mode 100644 tests/backend/test_pwa.py diff --git a/app/factory.py b/app/factory.py index 293bc10..51fbe97 100644 --- a/app/factory.py +++ b/app/factory.py @@ -84,6 +84,23 @@ def create_app() -> FastAPI: return FileResponse(favicon_path) return FileResponse(settings.base_dir / "favicon.ico") + @app.get("/manifest.json", include_in_schema=False) + async def manifest(): + """Serve le Web App Manifest pour la PWA.""" + return FileResponse( + settings.base_dir / "static" / "manifest.json", + media_type="application/manifest+json", + ) + + @app.get("/sw.js", include_in_schema=False) + async def service_worker(): + """Serve le Service Worker à la racine pour un scope maximal.""" + return FileResponse( + settings.base_dir / "static" / "sw.js", + media_type="application/javascript", + headers={"Service-Worker-Allowed": "/"}, + ) + @app.get("/api", response_class=HTMLResponse) async def api_home(): """Page d'accueil de l'API.""" diff --git a/app/index.html b/app/index.html index 3a9d511..5138f5f 100644 --- a/app/index.html +++ b/app/index.html @@ -10,6 +10,13 @@ + + + + + + +