Another bunch of fixes for presentation 1
This commit is contained in:
parent
5d70201516
commit
6d9f1a856d
@ -5,6 +5,15 @@ import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def build_post_payload(identifier, metadata_payload, file_payload):
|
||||
return {
|
||||
'id': identifier,
|
||||
'metadata': metadata_payload,
|
||||
'image_data': file_payload
|
||||
}
|
||||
|
||||
|
||||
def print_response(response):
|
||||
print("Code: " + str(response.status_code) + "; Body: " + str(response.json()))
|
||||
|
||||
@ -29,11 +38,8 @@ def send_image(identifier, image_path, metadata_payload):
|
||||
file_payload = file_encoded_b64.decode('utf-8')
|
||||
baseurl = "http://127.0.0.1:8000"
|
||||
post_url = "/image/post"
|
||||
body = {
|
||||
'id': identifier,
|
||||
'metadata': metadata_payload,
|
||||
'image_data': file_payload
|
||||
}
|
||||
body = build_post_payload(identifier, metadata_payload, file_payload)
|
||||
|
||||
try:
|
||||
response = requests.post(baseurl + post_url, json=body)
|
||||
print_response(response)
|
||||
@ -58,11 +64,7 @@ def update_image(identifier, image_path, metadata_payload):
|
||||
file_payload = file_encoded_b64.decode('utf-8')
|
||||
baseurl = "http://127.0.0.1:8000"
|
||||
post_url = "/image/update/" + identifier
|
||||
body = {
|
||||
'id': identifier,
|
||||
'metadata': metadata_payload,
|
||||
'image_data': file_payload
|
||||
}
|
||||
body = build_post_payload(identifier, metadata_payload, file_payload)
|
||||
try:
|
||||
response = requests.put(baseurl + post_url, json=body)
|
||||
print_response(response)
|
||||
@ -350,7 +352,6 @@ while (command.lower() not in ["exit", "quit", "end"]):
|
||||
meta_payload = metadata[index]
|
||||
filename = meta_payload['filename']
|
||||
get_image(filename[:-4])
|
||||
index = index + 1
|
||||
print_cursor()
|
||||
|
||||
if command.lower() == "fetchall":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user