File size: 601 Bytes
3fbc4f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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))