-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
30 lines (24 loc) · 794 Bytes
/
client.py
File metadata and controls
30 lines (24 loc) · 794 Bytes
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
import json
import os
import sys
import requests
# Path to an image file for testing
# Replace with a path to your own image file
filename = sys.argv[1] if len(sys.argv) > 1 else "snowman.png"
image_path = os.path.expanduser(filename)
# Check if the file exists
if not os.path.exists(image_path):
print(f"Error: Image file not found at {image_path}")
print("Please update the image_path variable to point to a valid image file")
exit(1)
# Prepare the files for upload
files = {"content": open(image_path, "rb")}
# Send the request to the API
try:
response = requests.post("http://127.0.0.1:8010/stats", files=files)
print(json.dumps(response.json(), indent=2))
except Exception as e:
print(f"Error: {e}")
finally:
# Close the file
files["content"].close()