Flask返回图片

512次阅读
没有评论

Flask 返回图片代码

@app.route("/api//status.png")
def tmp_image_status(tmpid):
    online = play.get_tmp_online(str(tmpid))
    if online == True:
        with open("static/images/online/online.png", 'rb') as bites:
            return send_file(io.BytesIO(bites.read()),
                attachment_filename='line.png',
                mimetype='image/png'
            )
    else:
        with open("static/images/online/offline.png", 'rb') as bites:
            return send_file(io.BytesIO(bites.read()),
                attachment_filename='offline.png',
                mimetype='image/png'
            )

 

 

 

正文完
 
ddn
版权声明:本站原创文章,由 ddn 2018-09-03发表,共计431字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。