Spaces:
Sleeping
Sleeping
| # test_client.py | |
| import requests | |
| # Test the FastAPI endpoint | |
| response = requests.post( | |
| "http://localhost:7860/visualize/natural", | |
| files={"file": open("data.xlsx", "rb")}, # Replace "data.xlsx" with your file | |
| data={"prompt": "Show sales over time", "return_type": "base64"} | |
| ) | |
| # Print the JSON response (contains Base64 image) | |
| print(response.json()) | |
| # To save the image (optional): | |
| if "image" in response.json(): | |
| import base64 | |
| image_data = response.json()["image"].split(",")[1] # Remove header | |
| with open("plot.png", "wb") as f: | |
| f.write(base64.b64decode(image_data)) |