Spaces:
Running
Running
| set -e | |
| # Export environment variables for the app | |
| export BACKEND_URL="http://127.0.0.1:8000" | |
| echo "Starting FastAPI backend on port 8000..." | |
| uvicorn app.api:app --host 0.0.0.0 --port 8000 & | |
| BACKEND_PID=$! | |
| # Wait for backend to be ready with health check | |
| echo "Waiting for backend to start..." | |
| for i in {1..30}; do | |
| if curl -s http://127.0.0.1:8000/health > /dev/null 2>&1; then | |
| echo "Backend is healthy!" | |
| break | |
| fi | |
| echo "Waiting... ($i/30)" | |
| sleep 2 | |
| done | |
| # Check if backend is running | |
| if ! kill -0 $BACKEND_PID 2>/dev/null; then | |
| echo "ERROR: Backend failed to start" | |
| exit 1 | |
| fi | |
| echo "Backend started successfully (PID: $BACKEND_PID)" | |
| echo "Starting Streamlit frontend on port 7860..." | |
| # Start Streamlit frontend on port 7860 (Hugging Face Spaces default) | |
| streamlit run streamlit_app.py --server.port 7860 --server.address 0.0.0.0 --server.headless true | |