We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I managed to get the image to rest but not verify it, I don't know how to do it, any help.
class CaptchaAPIView(APIView): permission_classes = [AllowAny] def get(self, request, *args, **kwargs): captcha_key = CaptchaStore.generate_key() image_url = captcha_image_url(captcha_key) img_response = captcha_image(key=captcha_key, request=image_url) img_base64 = base64.b64encode(img_response.getvalue()).decode('utf-8') captcha_key = CaptchaStore.generate_key() request.session['captcha_key'] = captcha_key return Response({'image_url': image_url, 'captcha_key': captcha_key, 'img_base64': img_base64}) def post(self, request, *args, **kwargs): user_response = request.data.get('captcha_response') print("user_response:", user_response) captcha_key = request.session.get('captcha_key') if captcha_key: hashed_user_response = hashlib.sha256(user_response.encode()).hexdigest() print("hashed",hashed_user_response) captcha = CaptchaStore.objects.filter(hashkey=captcha_key).first() if captcha and captcha.response == hashed_user_response: return HttpResponse('Captcha verification successful') else: return HttpResponse('Invalid captcha response', status=400) else: return HttpResponse('Captcha key not found in session', status=400)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I managed to get the image to rest but not verify it, I don't know how to do it, any help.
The text was updated successfully, but these errors were encountered: