来自matplotlib的django网站上的图像 [英] images on django site from matplotlib
问题描述
我正在寻找一种输入表单,您可以在其中输入服务器名称,并最终显示从matpotlib创建的多个png图像.
I am looking to have an entry form where you can enter in a server name and end up getting several png images displayed that are created from matpotlib.
我可以创建表单,并编写用于创建图像文件的脚本.我想知道处理图像的最佳方法是什么.有什么方法可以将生成的png文件显示到浏览器中,但不能将其保存到磁盘上?
I can create the form, and have the scripts written that create the image files. I am wondering what the best way to deal with the images are. Is there a way I can display the resulting png file to the browser but not save it to disk?
要避免在生成的图像显示在浏览器中后使目录混乱.我应该只在渲染后删除图像吗?
Want to avoid cluttering up a directory with the generated images after they are displayed the the browser. Should I just delete the image after its rendered?
推荐答案
response = HttpResponse(mimetype="image/png")
img.save(response, "PNG")
return response
这篇关于来自matplotlib的django网站上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!