File size: 1,378 Bytes
47bf2d4
 
 
 
 
 
 
a98cd12
47bf2d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45

import requests
import json
import socket

REMOTE_BASE = "https://destinyebuka-aida.hf.space"

def check_endpoint(path, method="GET", json_data=None):
    with open("remote_status.txt", "a") as f:
        url = f"{REMOTE_BASE}{path}"
        f.write(f"\n--- Checking {method} {url} ---\n")
        try:
            if method == "GET":
                resp = requests.get(url, timeout=10)
            elif method == "POST":
                resp = requests.post(url, json=json_data, timeout=10)
            elif method == "OPTIONS":
                resp = requests.options(url, timeout=10)
                
            f.write(f"Status: {resp.status_code}\n")
            f.write(f"Headers: {dict(resp.headers)}\n")
            try:
                f.write(f"Body: {resp.json()}\n")
            except:
                f.write(f"Body (text): {resp.text[:200]}...\n")
                
        except Exception as e:
            f.write(f"Error: {e}\n")

# 1. Check Root to see version/docs
check_endpoint("/")

# 2. Check AI Health to see version
check_endpoint("/ai/health")

# 3. Check /ai/ask with OPTIONS to see allowed methods
check_endpoint("/ai/ask", method="OPTIONS")

# 4. Check /ai/ask with POST to reproduce error
check_endpoint("/ai/ask", method="POST", json_data={"message": "ping"})

# 5. Check /ai/ask with GET just in case
check_endpoint("/ai/ask", method="GET")