def login_vcode(request): b = BytesIO() img, check = get_pic_code() img.save(b, format("png")) vcode = base64.b64encode(b.getvalue()) sign = str(uuid.uuid1()) set_vcode(sign, ''.join([str(i) for i in check]).lower()) return json_response(200, 'OK', { 'vcode': vcode.decode('utf-8'), 'sign': sign })
def login_vcode(request): """ 登录验证码获取 :param request: 请求对象 :return: vcode: 验证码图片的base64编码; sign: 校验码 """ b = BytesIO() img, check = get_pic_code() img.save(b, format='png') vcode = base64.b64encode(b.getvalue()) sign = str(uuid.uuid1()) set_vcode(sign, ''.join([str(i) for i in check]).lower()) return json_response(200, 'OK', { 'vcode': vcode.decode('utf-8'), 'sign': sign })