-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_full_flow.py
More file actions
39 lines (32 loc) · 1.11 KB
/
Copy pathtest_full_flow.py
File metadata and controls
39 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import sys
import requests
import json
IMAGE_FILENAME = "test_image.jpg"
URL = "http://localhost:8000/generate-catalog"
def main():
if not os.path.exists(IMAGE_FILENAME):
print(f"❌ {IMAGE_FILENAME} not found.")
sys.exit(1)
print(f"Uploading {IMAGE_FILENAME} to {URL}...")
try:
with open(IMAGE_FILENAME, "rb") as f:
files = {"file": (IMAGE_FILENAME, f, "image/jpeg")}
response = requests.post(URL, files=files)
if response.status_code == 200:
print("\n✅ Catalog Generated!")
data = response.json()
if "error" in data:
print(f"❌ Error reported by API: {data['error']}")
if "details" in data:
print(f"Details: {data['details']}")
else:
print(json.dumps(data, indent=2))
else:
print("\n❌ HTTP Error:")
print(f"Status: {response.status_code}")
print(response.text)
except Exception as e:
print(f"\n❌ Unexpected error: {e}")
if __name__ == "__main__":
main()