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")