webpy学习之serving images
来源:互联网 发布:网名生成器软件 编辑:程序博客网 时间:2024/06/06 04:39
</pre><p>1,新建文件目录../serving_images/,在该目录下面新建文件serving_images.py,文件内容如下:</p><p></p><p></p><pre name="code" class="python">mport webimport osurls = ( '/images/(.*)', 'images' #this is where the image folder is located....)class images: def GET(self,name): ext = name.split(".")[-1] # Gather extension #<span style="color:#33FF33;">返回获取的所有子字符串</span> cType = { "png":"images/png", "jpg":"images/jpeg", "gif":"images/gif", "ico":"images/x-icon" } if name in os.listdir('images'): # Security web.header("Content-Type", cType[ext]) # Set the Header return open('images/%s'%name,"rb").read() # Notice 'rb' for reading images else: raise web.notfound()app = web.application(urls, globals())if __name__ == '__main__': app.run()
在../serving_images/目录下创建images/目录,将你想要显示的图片放到该目录下,注意文件格式。然后,
python serving_images.py
登陆http://localhost:8080/image_name.png,即可提供图片下载查看功能。
0 0
- webpy学习之serving images
- Serving Images from .NET Assemblies
- webpy学习笔记之一
- webpy之shell
- webpy
- webpy
- webpy
- 【Python】Webpy 源码学习(转)
- Python学习笔记(初识webpy)
- TensorFlow学习笔记13----TensorFlow Serving
- 学习webpy官网示例笔记
- webpy 之svn 自助注册系统
- docker命令之images
- React Native 之 Images
- 【webpy】webpy笔记
- images
- images
- images
- oracle闪回技术
- C4D制作毛发舞动的Logo
- 封装
- 通过COM口管理LINUX服务器
- DXVA硬件加速解码
- webpy学习之serving images
- HDU 5056 Boring count(不超过k个字符的子串个数)
- Sql Server中系统函数有哪些
- ListView 中的每一项添加一个checkbox复选框,实现复选功能
- 压缩跟踪Compressive Tracking源码理解
- virtualbox学习相关网址
- Windows+caffe+libsvm对图片数据集的分类
- 关于数据查询分页
- Android基础入门教程——4.5.2 Intent之复杂数据的传递