File size: 1,269 Bytes
6d8f43a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import requests
import time
import sys

# Replace with your actual Space URL
SPACE_URL = "https://ajay-projects-vton-backend.hf.space"

def check_health():
    print(f"Checking health of {SPACE_URL}...")
    try:
        response = requests.get(f"{SPACE_URL}/health", timeout=10)
        if response.status_code == 200:
            print("✅ Backend is ONLINE!")
            print(f"Response: {response.json()}")
            return True
        else:
            print(f"❌ Backend returned status code: {response.status_code}")
            print(f"Response: {response.text}")
            return False
    except requests.exceptions.ConnectionError:
        print("❌ Could not connect to the server. Is the Space still building?")
        return False
    except Exception as e:
        print(f"❌ An error occurred: {e}")
        return False

if __name__ == "__main__":
    print("--- StableVITON Cloud Connection Test ---")
    
    # Simple retry loop
    max_retries = 5
    for i in range(max_retries):
        if check_health():
            sys.exit(0)
        
        if i < max_retries - 1:
            print("Waiting 30 seconds before retrying...")
            time.sleep(30)
    
    print("Could not connect after verified attempts.")
    sys.exit(1)