The following snippet of code generates a matplotlib plot and returns a png:
@app.route('/plot/')
def test_image():
fig, ax = plt.subplots(1)
plt.plot(np.arange(100), np.random.normal(0, 1, 100))
canvas = FigureCanvas(fig)
img = BytesIO()
fig.savefig(img)
img.seek(0)
return send_file(img, mimetype='image/png')
Embedding this in html:
<img src="{{ url_for('test_image') }}" alt="Image Placeholder" height="300">
works as expected. However, when trying to update the image using jquery:
$.get('/plot', function(image){
$("#weapImage").html('<img src="data:image/png;base64,'+image+'" />')
})
