Spaces:
Sleeping
Sleeping
| import requests | |
| import json | |
| BASE_URLS = [ | |
| "https://spam-fastapi-cjell.hf.space", | |
| "https://spam-fastapi-cjell.hf.space/api", | |
| "https://spam-fastapi-cjell.hf.space/docs", | |
| ] | |
| for base_url in BASE_URLS: | |
| print(f"\n🔹 Testing URL: {base_url}") | |
| try: | |
| # Test GET request | |
| print(f" GET {base_url}") | |
| resp = requests.get(base_url, timeout=10) | |
| print(f" Status: {resp.status_code}") | |
| print(f" Content-Type: {resp.headers.get('content-type', 'N/A')}") | |
| if resp.status_code == 200: | |
| try: | |
| print(f" JSON: {resp.json()}") | |
| except: | |
| print(f" Text (first 200 chars): {resp.text[:200]}") | |
| else: | |
| print(f" Error text (first 200 chars): {resp.text[:200]}") | |
| except requests.exceptions.RequestException as e: | |
| print(f" Request failed: {e}") | |
| # Test the root URL specifically for POST | |
| print(f"\n🔹 Testing POST to main URL...") | |
| try: | |
| resp = requests.post( | |
| "https://spam-fastapi-cjell.hf.space", | |
| json={"text": "Hello test"}, | |
| headers={"Content-Type": "application/json"}, | |
| timeout=10 | |
| ) | |
| print(f" POST Status: {resp.status_code}") | |
| print(f" POST Response: {resp.text[:200]}") | |
| except requests.exceptions.RequestException as e: | |
| print(f" POST failed: {e}") |