如何在djangi中的html模板中访问views.py文件中存在的图形

时间:2018-10-23 16:45:54

标签: python django matplotlib

我有如下的views.py文件

Def showimage(请求):     #构造图     t =范围(0.0,2.0,0.01)     s = sin(2 * pi * t)     plot(t,s,linewidth = 1.0)

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)


buffer = StringIO.StringIO()
canvas = pylab.get_current_fig_manager().canvas
canvas.draw()
pilImage = PIL.Image.frombytes("RGB", canvas.get_width_height(), canvas.tostring_rgb())
pilImage.save(buffer, "PNG")
pylab.close()

您能不能请我将该图传递到html页面中??

0 个答案:

没有答案