spam_fastapi / test.py
cjell
slash
c56e8db
raw
history blame contribute delete
840 Bytes
import requests
BASE_URL = "http://cjell-spam-fastapi.hf.space"
# --- Health check ---
print("🔹 Checking health endpoint...")
health_resp = requests.get(BASE_URL + "/")
print("Health check status:", health_resp.status_code)
try:
print("Health check JSON:", health_resp.json())
except Exception:
print("Health check raw text:", health_resp.text[:500]) # first 500 chars
# --- Prediction request ---
print("\n🔹 Sending prediction request...")
predict_resp = requests.post(
BASE_URL + "/predict",
json={"text": "Congratulations! You've won a free cruise!"},
headers={"Content-Type": "application/json"},
timeout=30
)
print("Prediction status:", predict_resp.status_code)
try:
print("Prediction JSON:", predict_resp.json())
except Exception:
print("Prediction raw text:", predict_resp.text[:500])