Skip to content

Commit 47449d6

Browse files
committed
Fix missing favicon
1 parent 8e0c79f commit 47449d6

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/server.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
from pathlib import Path
44

5-
from fastapi import FastAPI, HTTPException
5+
from fastapi import FastAPI, HTTPException, Response
66
from fastapi.responses import HTMLResponse
7+
from fastapi.staticfiles import StaticFiles
78

89
BASE_DIR = Path(__file__).resolve().parent.parent
910
WEB_DIR = BASE_DIR / "web"
1011
INDEX_PATH = WEB_DIR / "index.html"
1112
ALADIN_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

1315
app = FastAPI(title="NASA Sky Explorer Prototype")
16+
app.mount("/static", StaticFiles(directory=WEB_DIR), name="static")
1417

1518

1619
def _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)
3034
def 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+
3546
if __name__ == "__main__":
3647
import uvicorn
3748

web/aladin.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width" />
66
<title>NASA Sky Viewer</title>
7-
<link rel="stylesheet" href="./web/styles.css" />
7+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%230f172a'/%3E%3Cpath fill='%23facc15' 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'/%3E%3C/svg%3E" />
8+
<link rel="stylesheet" href="/static/styles.css" />
89
</head>
910
<body>
1011
<div id='aladin-lite-div' style='width: 500px; height: 500px;'></div>

web/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />
66
<title>NASA Sky Explorer Prototype</title>
7+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%230f172a'/%3E%3Cpath fill='%23facc15' 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'/%3E%3C/svg%3E" />
78
<style>
89
body {
910
margin: 0;

0 commit comments

Comments
 (0)