Add python examples

This commit is contained in:
Harrison Burt 2022-03-29 21:52:34 +01:00
parent 4846d75d23
commit 6e5871389c
2 changed files with 22 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/data
/target
/venv

21
examples/upload.py Normal file
View File

@ -0,0 +1,21 @@
import requests
with open("./example.jpeg", "rb") as file:
image = file.read()
r = requests.post(
"http://127.0.0.1:8000/v1/user-profiles",
params={"format": "jpeg"},
headers={
"content-length": str(len(image)),
"content-type": "application/octet-stream"
},
data=image,
)
r.raise_for_status()
data = r.json()
print("My image id: {}", data['image_id'])
print("It took {}s to complete!", data['processing_time'])
print("And has a checksum of {}!", data['checksum'])