验证码¶
code_img, strs = create_validate_code()
session['code_text'] = strs
buf = StringIO.StringIO()
code_img.save(buf, 'JPEG', quality=70)
buf_str = buf.getvalue()
response = app.make_response(buf_str)
response.headers['Content-Type'] = 'image/jpeg'
return response
函数create_validate_code代码见validation.py,不太看得懂