#!/bin/bash echo "⏳ Waiting for Space to restart and load YOUTUBE_API_KEY..." echo "" for i in {1..30}; do echo -n "Attempt $i/30: " # Check if space is responding STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://ocx2025-basicsearch.hf.space/health 2>/dev/null) if [ "$STATUS" = "200" ]; then echo "✅ Space is UP!" echo "" echo "Testing YouTube API..." curl -X POST https://ocx2025-basicsearch.hf.space/search \ -H "Content-Type: application/json" \ -d '{"query": "Python programming", "max_results": 1}' \ 2>/dev/null | python3 -m json.tool exit 0 elif [ "$STATUS" = "404" ]; then echo "⚠️ 404 (Space might be private or still building)" else echo "⏳ Building... (Status: $STATUS)" fi sleep 6 done echo "" echo "❌ Timeout waiting for Space. Please check manually:" echo "https://huggingface.co/spaces/ocx2025/basicsearch"