def ImgCode(): text, img = Captcha.gene_code() #生成数字和背景图 print(text) #在服务器中打印出生成的验证码 out = BytesIO() img.save(out, 'png') out.seek(0) saveCache(text, text, 60) #60秒有效时 resp = make_response(out.read()) resp.content_type = 'image/png' return resp
def ima_code(): text, img = Captcha.gene_code() out = BytesIO() img.save(out, 'png') out.seek(0) saveCode(text, text) print(text) reso = make_response(out.read()) reso.content_type = "image/png" return reso
def ImgCode(): # 生成6位的字符串 # 把这个字符串放在图片上 # 用特殊字体 # 添加横线 # 添加噪点 text, img = Captcha.gene_code() # 通过工具类生成验证码 print(text) out = BytesIO() # 初始化流对象 img.save(out, 'png') # 保存成png格式 out.seek(0) # 从文本的开头开始读 saveCache(text, text, 60) resp = make_response(out.read()) # 根据流对象生成一个响应 resp.content_type = "image/png" # 设置响应头中content-type return resp