AI-label-tool / server.py
sunyoung00's picture
Upload 6 files
15f041f verified
"""
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)