2020
10-04
10-04
Python flask框架如何显示图像到web页面
代码如下webfig1.pyfromflaskimportFlaskfromflaskimportrender_templateimportmatplotlib.pyplotaspltimportioimportbase64app=Flask(__name__)@app.route('/')defbuild_plot():img=io.BytesIO()y=[1,2,3,4,5]x=[0,2,1,3,4]plt.plot(x,y)plt.savefig(img,format='png')img.seek(0)plot_url=base64.b64encode(img.getvalue()).decode()returnrender_template('plot.html',plot_url=plot_...
继续阅读 >