Erste Produktivversion
This commit is contained in:
56
backend/app/routers/appinfo.py
Normal file
56
backend/app/routers/appinfo.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Angaben zur Anwendung, die die Oberflaeche zur Laufzeit braucht.
|
||||
|
||||
Die statischen Dateien im web-Container kennen den Anwendungsnamen nicht -
|
||||
er steht in der .env. Statt ihn beim Bauen einzusetzen (was ein
|
||||
Neubau-Erfordernis bei jeder Umbenennung bedeutete), liefert ihn die API.
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from app.config import settings
|
||||
|
||||
router = APIRouter(tags=["app"])
|
||||
|
||||
|
||||
@router.get("/api/config")
|
||||
def public_config():
|
||||
"""Ohne Anmeldung erreichbar: Das Anmeldeformular braucht den Namen,
|
||||
bevor jemand angemeldet ist. Enthaelt bewusst nichts Vertrauliches."""
|
||||
return {
|
||||
"app_name": settings.app_name,
|
||||
"app_short_name": settings.short_name,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/manifest.webmanifest", include_in_schema=False)
|
||||
def manifest():
|
||||
"""Erzeugt statt statisch ausgeliefert, damit der Name aus der .env
|
||||
auch auf dem Startbildschirm erscheint."""
|
||||
return JSONResponse(
|
||||
{
|
||||
"name": settings.app_name,
|
||||
"short_name": settings.short_name,
|
||||
"description": "Gemeinsame Einkaufslisten mit Märkten, "
|
||||
"Warengruppen und Preisen.",
|
||||
"lang": "de",
|
||||
"dir": "ltr",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait-primary",
|
||||
"background_color": "#f6f6f4",
|
||||
"theme_color": "#2f6f4e",
|
||||
"categories": ["shopping", "productivity"],
|
||||
"icons": [
|
||||
{"src": "/icons/icon-192.png", "sizes": "192x192",
|
||||
"type": "image/png", "purpose": "any"},
|
||||
{"src": "/icons/icon-512.png", "sizes": "512x512",
|
||||
"type": "image/png", "purpose": "any"},
|
||||
{"src": "/icons/icon-maskable-512.png", "sizes": "512x512",
|
||||
"type": "image/png", "purpose": "maskable"},
|
||||
],
|
||||
},
|
||||
media_type="application/manifest+json",
|
||||
headers={"Cache-Control": "no-cache"},
|
||||
)
|
||||
Reference in New Issue
Block a user