Spaces:
Running
Running
File size: 678 Bytes
ec720bb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import requests
import time
import sys
def verify():
print("Verifying Backend Health...")
url = "http://127.0.0.1:7860/api/health"
try:
# Retry logic for startup
for i in range(5):
try:
res = requests.get(url)
if res.status_code == 200:
print("✅ Backend is Online")
return
except:
print(f"Waiting for server... ({i+1}/5)")
time.sleep(2)
print("❌ Backend failed to start")
sys.exit(1)
except Exception as e:
print(f"Error: {e}")
sys.exit(1)
if __name__ == "__main__":
verify()
|