# app.py # FastAPI 서버 + Real3D FlipBook 정적 사이트 # 모든 정적 파일(JS / CSS / MP3 / 이미지 등)과 이 파일을 같은 폴더에 둡니다. from fastapi import FastAPI from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles import pathlib, os, uvicorn BASE = pathlib.Path(__file__).parent app = FastAPI() # ───────────────────────────────────────────────────────────── # 1) /static → 현재 폴더(라이브러리·MP3·이미지) 서빙 # ───────────────────────────────────────────────────────────── app.mount("/static", StaticFiles(directory=BASE), name="static") # ───────────────────────────────────────────────────────────── # 2) index.html 원문 (오디오 경로 /static/turnPage2.mp3 로 수정) # ───────────────────────────────────────────────────────────── INDEX_HTML = """ FlipBook – 업로드 + 사운드

Real3D FlipBook – 이미지 업로드 📷✨

""" # ───────────────────────────────────────────────────────────── # 3) 루트 경로 → index.html 반환 # ───────────────────────────────────────────────────────────── @app.get("/", response_class=HTMLResponse) async def root(): return INDEX_HTML # ───────────────────────────────────────────────────────────── # 4) Hugging Face Spaces가 python app.py 로 실행 시 서버 기동 # ───────────────────────────────────────────────────────────── if __name__ == "__main__": port = int(os.environ.get("PORT", 7860)) uvicorn.run("app:app", host="0.0.0.0", port=port, reload=False)