Spaces:
Sleeping
Sleeping
| # Startup script for HuggingFace Spaces | |
| # Runs both FastAPI backend and Gradio frontend | |
| echo "π Starting Anthropic Topic Segmentation Microservice..." | |
| # Start FastAPI backend in the background | |
| echo "π‘ Starting FastAPI backend on port 8000..." | |
| uvicorn app:app --host 0.0.0.0 --port 8000 --workers 1 & | |
| FASTAPI_PID=$! | |
| # Wait a moment for FastAPI to start | |
| sleep 5 | |
| # Check if FastAPI is running | |
| if curl -f http://localhost:8000/health > /dev/null 2>&1; then | |
| echo "β FastAPI backend is healthy" | |
| else | |
| echo "β FastAPI backend failed to start" | |
| exit 1 | |
| fi | |
| # Start Gradio frontend on port 7860 (HuggingFace Spaces standard) | |
| echo "π¨ Starting Gradio frontend on port 7860..." | |
| python gradio_app.py | |
| # If Gradio exits, also stop FastAPI | |
| echo "π Stopping services..." | |
| kill $FASTAPI_PID 2>/dev/null || true | |
| wait |