default.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:CF401-Project-1---PyListener 作者: PyListener 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号