| set -e | |
| # Get port from environment variable (Hugging Face Spaces sets this) | |
| PORT=${PORT:-7860} | |
| echo "Starting FastAPI application on port $PORT..." | |
| # Verify critical imports before starting | |
| echo "Verifying imports..." | |
| python -c "import sys; sys.path.insert(0, '/app'); import app; print('✓ app.py imported successfully')" || { | |
| echo "ERROR: Failed to import app.py" | |
| exit 1 | |
| } | |
| # Run the FastAPI application | |
| echo "Starting uvicorn server..." | |
| exec python -m uvicorn app:app --host 0.0.0.0 --port $PORT --log-level info | |