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