图形验证码
This commit is contained in:
@@ -8,7 +8,7 @@ def gen_captcha(content='2345689abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWX
|
||||
""" 生成验证码 """
|
||||
image = ImageCaptcha()
|
||||
# 获取字符串
|
||||
captcha_text = "".join(choices(content, k=4))
|
||||
captcha_text = "".join(choices(content, k=4)).lower()
|
||||
# 生成图像
|
||||
captcha_image = Image.open(image.generate(captcha_text))
|
||||
return captcha_text, captcha_image
|
||||
|
||||
@@ -35,7 +35,7 @@ def login_post():
|
||||
req = request.form
|
||||
username = req.get('username')
|
||||
password = req.get('password')
|
||||
code = req.get('captcha')
|
||||
code = req.get('captcha').__str__().lower()
|
||||
|
||||
if not username or not password or not code:
|
||||
return fail_api(msg="用户名或密码没有输入")
|
||||
|
||||
Reference in New Issue
Block a user