|
7 | 7 |
|
8 | 8 | import httpx |
9 | 9 | from fastapi import FastAPI, HTTPException, Response |
| 10 | +from fastapi.responses import HTMLResponse |
| 11 | +from fastapi.staticfiles import StaticFiles |
10 | 12 | from app.mardi_item_helper import BASE_IRI |
11 | 13 | from fdo_schemas.publication import build_scholarly_article_payload |
12 | 14 | from fdo_schemas.author import build_author_payload |
|
20 | 22 | version="0.1.0", |
21 | 23 | ) |
22 | 24 |
|
| 25 | +app.mount("/static", StaticFiles(directory="static"), name="static") |
| 26 | + |
23 | 27 |
|
24 | 28 | @lru_cache(maxsize=2048) |
25 | 29 | def fetch_entity(qid: str) -> Dict[str, Any]: |
@@ -171,6 +175,58 @@ def to_fdo_minimal(qid: str, entity: Dict[str, Any]) -> Dict[str, Any]: |
171 | 175 | "schema:Person": to_fdo_author, |
172 | 176 | } |
173 | 177 |
|
| 178 | + |
| 179 | +@app.get("/", response_class=HTMLResponse) |
| 180 | +async def root() -> HTMLResponse: |
| 181 | + """Render a greeting with a usage hint on the landing page. |
| 182 | +
|
| 183 | + Returns: |
| 184 | + HTMLResponse: Greeting and sample FDO link with styled background. |
| 185 | + """ |
| 186 | + body = """ |
| 187 | + <html> |
| 188 | + <head> |
| 189 | + <style> |
| 190 | + body { |
| 191 | + margin: 0; |
| 192 | + padding: 0; |
| 193 | + font-family: Arial, sans-serif; |
| 194 | + color: #0b132b; |
| 195 | + background: url('/static/background_mardi_api.png') no-repeat center center fixed; |
| 196 | + background-size: cover; |
| 197 | + } |
| 198 | + .overlay { |
| 199 | + background-color: rgba(255, 255, 255, 0.85); |
| 200 | + max-width: 720px; |
| 201 | + margin: 12vh auto; |
| 202 | + padding: 32px 36px; |
| 203 | + border-radius: 12px; |
| 204 | + box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); |
| 205 | + } |
| 206 | + a { |
| 207 | + color: #1a73e8; |
| 208 | + text-decoration: none; |
| 209 | + font-weight: 600; |
| 210 | + } |
| 211 | + a:hover { |
| 212 | + text-decoration: underline; |
| 213 | + } |
| 214 | + </style> |
| 215 | + </head> |
| 216 | + <body> |
| 217 | + <div class="overlay"> |
| 218 | + <p>Hello, this is the MaRDI FDO service.</p> |
| 219 | + <p> |
| 220 | + This API delivers FAIR Digital Object payloads for MaRDI QIDs. |
| 221 | + Try <a href="/fdo/Q2055155">/fdo/Q2055155</a>. |
| 222 | + </p> |
| 223 | + </div> |
| 224 | + </body> |
| 225 | + </html> |
| 226 | + """ |
| 227 | + return HTMLResponse(content=body) |
| 228 | + |
| 229 | + |
174 | 230 | @app.get("/fdo/{qid}") |
175 | 231 | async def get_fdo(qid: str) -> Dict[str, Any]: |
176 | 232 | """Return a minimal FDO view for a MaRDI entity.""" |
|
0 commit comments