File size: 1,000 Bytes
15f041f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
AI Label Stamper โ€” FastAPI static server
์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ๋Š” ์ „๋ถ€ ๋ธŒ๋ผ์šฐ์ €(Canvas)์—์„œ ์ˆ˜ํ–‰๋˜๋ฏ€๋กœ ์„œ๋ฒ„๋Š” index.html ๋งŒ ์„œ๋น™ํ•ฉ๋‹ˆ๋‹ค.
"""
from pathlib import Path

from fastapi import FastAPI
from fastapi.responses import FileResponse, JSONResponse

BASE_DIR = Path(__file__).parent
INDEX_FILE = BASE_DIR / "index.html"

app = FastAPI(
    title="AI Label Stamper",
    description="Client-side image AI-label stamper",
    version="1.0.0",
    docs_url=None,
    redoc_url=None,
)


@app.get("/", response_class=FileResponse)
async def root():
    """Serve the SPA entry point."""
    return FileResponse(INDEX_FILE, media_type="text/html; charset=utf-8")


@app.get("/healthz")
async def healthz():
    """Health check endpoint used by Spaces to verify the container is alive."""
    return JSONResponse({"ok": True})


# Favicon์ด ์—†์–ด์„œ 404 ๋กœ๊ทธ๊ฐ€ ๊ณ„์† ๋œจ๋Š” ๊ฒƒ ๋ฐฉ์ง€
@app.get("/favicon.ico")
async def favicon():
    return JSONResponse({}, status_code=204)