def picture_handler(request):
"""Serve pictures from database binaries."""
if request.matchdict["db_id"] == "add":
picture_data = request.dbsession.query(AddressBook).get(request.matchdict['pic_id'])
elif request.matchdict["db_id"] == "cat":
picture_data = request.dbsession.query(Category).get(request.matchdict['pic_id'])
elif request.matchdict["db_id"] == "att":
picture_data = request.dbsession.query(Attribute).get(request.matchdict['pic_id'])
mime_type = picture_data.pic_mime
if sys.version_info[0] < 3:
mime_type = mime_type.encode('utf-8')
return Response(content_type=mime_type, body=picture_data.picture)
default.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录