My flask python app return an image as a response from a POST request:
def upload_file():
if request.method == 'POST':
return send_file('1.png', mimetype='image/png')
Then I want to use javascript and jquery ajax to do the request, and the response is:
success: function(img_response) {
console.log(img_response);
}
�PNG ��� IHDR����������?1�� �IDATx����nIv��vdU�Ѓ�ۀm6f`�����?���W3�1��%6Y��ER�xh�Pb��]�R�DfeFF�qo��_����O�4�]J$��.�%E�%E�ɲ$)...
How can I render this type of file in browser? Maybe is better decode the image in base64 in flask, but how can I do it?
success: function(img_response) { $('#image').html('<img src="data:image/png;base64,' + img_response + '" />'); },