Skip to content

Instantly share code, notes, and snippets.

@youqingkui
Last active August 29, 2015 14:25
Show Gist options
  • Save youqingkui/7b29dea3ca4fc53dd4c2 to your computer and use it in GitHub Desktop.
Save youqingkui/7b29dea3ca4fc53dd4c2 to your computer and use it in GitHub Desktop.
访问路由,读取本地图片文件并返回
import os
from flask make_response
file_path = os.path.join(os.getcwd(), 'app/templates/email/shadow_img.png')
img_content = 'image/png'
log_debug(file_path)
img = open(file_path).read()
response = make_response(img)
response.headers['Content-Type'] = img_content
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment