Spaces:
Sleeping
Sleeping
Download main.py from mahrooshishaq/Smartfolio-python: direct link, hf CLI and curl.
- Browser
- Download file 810 Bytes
-
https://huggingface.co/spaces/mahrooshishaq/Smartfolio-python/resolve/main/main.py
- Command line
-
hf download hf://spaces/mahrooshishaq/Smartfolio-python/main.py
-
curl -L -o main.py https://huggingface.co/spaces/mahrooshishaq/Smartfolio-python/resolve/main/main.py
810 Bytes
| import os | |
| import threading | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from routers import extraction, tts | |
| from services import tts_service | |
| async def lifespan(app: FastAPI): | |
| # Warm the TTS model off the request path so the first /tts call doesn't | |
| # pay model-load cost. Runs in a daemon thread; if TTS deps are missing it | |
| # quietly no-ops and /tts keeps degrading to 503. Disable with TTS_WARMUP=0. | |
| if os.getenv("TTS_WARMUP", "1") != "0": | |
| threading.Thread(target=tts_service.warmup, daemon=True).start() | |
| yield | |
| app = FastAPI(title="Smartfolio Python Service", version="1.0.0", lifespan=lifespan) | |
| app.include_router(extraction.router) | |
| app.include_router(tts.router) | |
| def health(): | |
| return {"status": "ok"} | |