Skip to content

Instantly share code, notes, and snippets.

View earthtrip's full-sized avatar

Mike Engelhart earthtrip

  • Cape Ann
View GitHub Profile
@earthtrip
earthtrip / recaptcha.html
Created December 19, 2013 19:48
Simple Recaptcha validation HTML form fragment when using Google App Engine (GAE), Webapp2 and WTForms.
<label>Verify you're human:</label>
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=YOUR_RECAPTCH_PUBLIC_KEY_HERE">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=YOUR_RECAPTCH_PUBLIC_KEY_HERE" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>
@earthtrip
earthtrip / recaptcha_validate.py
Created December 19, 2013 19:45
Simple Recaptcha validation method when using Google App Engine (GAE), Webapp2 and WTForms.
def validate_captcha(self, form):
recaptcha_challenge_field = self.request.get("recaptcha_challenge_field")
recaptcha_response_field = self.request.get("recaptcha_response_field")
remote_ip = self.request.remote_addr
recaptcha_private_key = 'MY_PRIVATE_KEY' # put recaptcha private key here
recaptcha_post_data = {"privatekey": recaptcha_private_key,
"remoteip": remote_ip,
"challenge": recaptcha_challenge_field,
"response": recaptcha_response_field}