webcraft-ai-backend / test_api_builder.py
Assem0's picture
RAG V1
9b7359e
Raw
History Blame Contribute Delete
707 Bytes
import requests
import json
url = "http://localhost:8000/ai_builder"
payload = {
"prompt": "Create a simple hero section with a blue background and title 'Hello World'"
}
print(f"πŸš€ Sending request to {url}...")
try:
# Use data= (Form-data) instead of json=
response = requests.post(url, data=payload, timeout=60)
print(f"Status Code: {response.status_code}")
with open("api_response.json", "w", encoding="utf-8") as f:
f.write(response.text)
if response.status_code == 200:
print("βœ… SUCCESS!")
print(json.dumps(response.json(), indent=2))
else:
print("❌ FAILED! See api_response.json")
except Exception as e:
print(f"❌ Error: {e}")