Last active
August 29, 2015 14:25
-
-
Save youqingkui/7b29dea3ca4fc53dd4c2 to your computer and use it in GitHub Desktop.
访问路由,读取本地图片文件并返回
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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