Yeetek's picture
Upload 17 files
b3e0a65 verified
raw
history blame contribute delete
840 Bytes
#!/bin/bash
# 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