webcraft-ai-backend / deploy_tmp /test_api_builder.py
3ssem0
fix: configuration error - aligned entry point to app.py and enforced LF/BOM-less encoding
ec47953
Raw
History Blame Contribute Delete
729 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}")