From a Python Flask API, I want to return an image stream and also some text in a single API response.
Something like this:
{
'Status' : 'Success',
'message': message,
'ImageBytes': imageBytes
}
Also, I would like to know what would be the best format to use for imageBytes, so that the client applications (Java / JQuery) can parse and reconstruct the image.
If the above approach is not correct, please suggest a better approach.
{ 'Status' : 'Success', 'message': message, 'ImageBytes': imageBytes }? You could send image in JPG format - it should have less bytes then other formats, and some Java / JQuery should have function to display it. In flask you can usepillow + io.BytesIOto create JPG in memory without saving in file.