Created
July 11, 2009 07:34
-
-
Save jpoz/145150 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'sinatra' | |
require 'sinatra/recaptcha' | |
configure do | |
# https://admin.recaptcha.net/accounts/signup/ | |
Sinatra::ReCaptcha.public_key = 'your_public_key' | |
Sinatra::ReCaptcha.private_key = 'your_private_key' | |
# to use ssl set Sinatra::ReCaptcha.server = 'https://api-secure.recaptcha.net' | |
end | |
get '/' do | |
haml :recaptcha | |
end | |
post '/' do | |
halt(401, "invalid captcha") unless captcha_correct? | |
"passed!" | |
end | |
__END__ | |
@@ captcha | |
%h1 Try ReCaptcha | |
%form{:method=>"post", :action=>"/post"} | |
= recaptcha | |
# you can also use recaptcha(:ajax) to use a pure ajax version | |
%input{:type=>'submit', :value => 'Send'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment