import requests
import json
import subprocess
target = 'https://trace.moe/api/search'
headers = {"Content-Type": "application/json"}
my_encoded_image = subprocess.check_output(['base64', '-w', '0', 'example.jpg'], encoding='utf-8')
data = json.dumps({"image": my_encoded_image})
r = requests.post(url=target, data=data, headers=headers)
imageSended = (r.status_code)
if imageSended == 200:
print('Success')
else:
print('Failed. Status code: {}'.format(imageSended))