Last active
July 13, 2018 08:11
-
-
Save anishmenon/1630377c03ed4f04eaf08de838069c6d to your computer and use it in GitHub Desktop.
recap.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result = requests.post('https://www.google.com/recaptcha/api/siteverify',\ | |
data = {'secret':private_key,'remoteip':get_client_ip(request),'response':rp('token')},verify=True) | |
if result.json()['success']: | |
def get_client_ip(request): | |
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') | |
if x_forwarded_for: | |
ip = x_forwarded_for.split(',')[0] | |
else: | |
ip = request.META.get('REMOTE_ADDR') | |
return ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment