that's my flask test route which should give image:
@app.route('/marknext', methods=['GET', 'POST'])
def marknext():
id = request.form.get("ID")
if request.method == 'POST':
return "OK"
else:
image_file_path = '/home/cnd/contrib/python/input/ChinaSet_AllFiles/CXR_png/CHNCXR_0370_1.png'
# res = make_response(send_file(image_file_path, add_etags=False, cache_timeout=0))
# return res
return send_file(image_file_path, add_etags=False, cache_timeout=0, attachment_filename='CHNCXR_0370_1.png')
and on client side I'm trying to get that file with axios and put it into <img>
axios.get('/marknext', {
params: {
ID: 0
}
})
.then(function (response) {
var reader = new window.FileReader();
reader.readAsDataURL(response.data);
reader.onload = function() {
var imageDataUrl = reader.result;
$("#selected-image").attr("src", imageDataUrl)
}
})
.catch(function (error) {
console.log(error);
})
.then(function () {
// always executed
});
And I'm getting my Error on console:
TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.
at mark.js:14
What am I doing wrong?