File size: 1,359 Bytes
a3fe9c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
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}")