Add PWA install badge for desktop and tablet (manifest, SW, Add to Home Screen).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -128,6 +128,41 @@ _DIST = resolve_frontend_dist()
|
||||
if (_DIST / "assets").is_dir():
|
||||
app.mount("/assets", StaticFiles(directory=str(_DIST / "assets")), name="assets")
|
||||
|
||||
_ICONS = _DIST / "icons"
|
||||
if _ICONS.is_dir():
|
||||
app.mount("/icons", StaticFiles(directory=str(_ICONS)), name="icons")
|
||||
|
||||
|
||||
def _dist_file(name: str) -> Path:
|
||||
return _DIST / name
|
||||
|
||||
|
||||
@app.get("/manifest.webmanifest")
|
||||
async def web_manifest():
|
||||
path = _dist_file("manifest.webmanifest")
|
||||
if not path.exists():
|
||||
raise HTTPException(status_code=404, detail="manifest missing")
|
||||
return FileResponse(
|
||||
path,
|
||||
media_type="application/manifest+json",
|
||||
headers={"Cache-Control": "no-cache"},
|
||||
)
|
||||
|
||||
|
||||
@app.get("/sw.js")
|
||||
async def service_worker():
|
||||
path = _dist_file("sw.js")
|
||||
if not path.exists():
|
||||
raise HTTPException(status_code=404, detail="service worker missing")
|
||||
return FileResponse(
|
||||
path,
|
||||
media_type="application/javascript",
|
||||
headers={
|
||||
"Cache-Control": "no-cache",
|
||||
"Service-Worker-Allowed": "/",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def index_page():
|
||||
|
||||
Reference in New Issue
Block a user