22
33from pathlib import Path
44
5- from fastapi import FastAPI , HTTPException
5+ from fastapi import FastAPI , HTTPException , Response
66from fastapi .responses import HTMLResponse
7+ from fastapi .staticfiles import StaticFiles
78
89BASE_DIR = Path (__file__ ).resolve ().parent .parent
910WEB_DIR = BASE_DIR / "web"
1011INDEX_PATH = WEB_DIR / "index.html"
1112ALADIN_PATH = WEB_DIR / "aladin.html"
13+ FAVICON_SVG = """<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'>\n <rect width='32' height='32' rx='8' fill='#0f172a'/>\n <path fill='#facc15' d='M16 4l3.4 7 7.6.7-5.8 5.2 1.8 7.6-7-4.2-7 4.2 1.8-7.6-5.8-5.2 7.6-.7z'/>\n </svg>"""
1214
1315app = FastAPI (title = "NASA Sky Explorer Prototype" )
16+ app .mount ("/static" , StaticFiles (directory = WEB_DIR ), name = "static" )
1417
1518
1619def _read_html (path : Path ) -> str :
@@ -27,11 +30,19 @@ def read_index() -> str:
2730
2831
2932@app .get ("/aladin" , response_class = HTMLResponse )
33+ @app .get ("/aladin/" , response_class = HTMLResponse )
3034def read_aladin () -> str :
3135 """Serve the Aladin viewer page."""
3236
3337 return _read_html (ALADIN_PATH )
3438
39+
40+ @app .get ("/favicon.ico" , include_in_schema = False )
41+ def favicon () -> Response :
42+ """Return a small SVG favicon to satisfy browser requests."""
43+
44+ return Response (content = FAVICON_SVG , media_type = "image/svg+xml" )
45+
3546if __name__ == "__main__" :
3647 import uvicorn
3748
0 commit comments