Skip to content

Instantly share code, notes, and snippets.

@baudneo
Created November 7, 2021 10:57
Show Gist options
  • Save baudneo/c72179301c7ad4dab95c3706d84527bc to your computer and use it in GitHub Desktop.
Save baudneo/c72179301c7ad4dab95c3706d84527bc to your computer and use it in GitHub Desktop.
# Other attempt
response = requests.post(to the api that serves images)
r = response
img = np.asarray(bytearray(response.content), dtype="uint8")
image = cv2.imdecode(img, cv2.IMREAD_COLOR) # RGB ?
object['thing'] = image
# Now to send it in the response
img = object['thing'].tobytes()
response = make_response(img)
response.headers['ML-Data'] = detection_data
response.headers['Content-Disposition'] = "attachment; filename='image.jpg'"
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment