Spaces:
Sleeping
Sleeping
| 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}") | |