共计 431 个字符,预计需要花费 2 分钟才能阅读完成。
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'
)
正文完