Spaces:
Sleeping
Sleeping
| 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) | |