#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" API_HOST="${API_HOST:-0.0.0.0}" API_PORT="${PORT:-7860}" : "${DATABASE_URL:?DATABASE_URL is not set. Add it as a Hugging Face Space Secret (Settings → Repository secrets).}" echo "Starting FastAPI + Gradio (mounted at /ui) on http://${API_HOST}:${API_PORT} ..." echo "UI: http://localhost:${API_PORT}/ui" echo "API Docs: http://localhost:${API_PORT}/docs" # Internal API URL for Gradio to use export KEYVAULT_BASE_URL="http://127.0.0.1:8000" # Run on PORT (7860 for HF Spaces) - FastAPI will mount Gradio at /ui uv run uvicorn main:app --host "${API_HOST}" --port "${API_PORT}"