Created
November 23, 2011 19:42
-
-
Save sergeyromanov/1389681 to your computer and use it in GitHub Desktop.
Test reCAPTCHA plugin for Mojolicious
This file contains hidden or 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
#!/usr/bin/perl | |
use Mojolicious::Lite; | |
plugin recaptcha => { | |
public_key => '...', # my public reCAPTCHA key | |
private_key => '...', # my private reCAPTCHA key | |
lang => 'ru' | |
}; | |
get '/' => sub { $_[0]->render('captcha') }; | |
post '/' => sub { | |
my $self = shift; | |
$self->recaptcha; | |
my $msg = $self->stash('recaptcha_error') ? "Correct" : "Wrong"; | |
$self->render(message => $msg, template => 'result'); | |
}; | |
app->start; | |
__DATA__ | |
@@ captcha.html.ep | |
<html><body> | |
<form action="/" method="post"> | |
<%= recaptcha_html %> | |
<input type="submit" value="submit" name="submit" /> | |
</form> | |
</body></html> | |
@@ result.html.ep | |
<html><body> | |
<h1><%= $message %></h1> | |
<h3><a href="">Try again!</a></h3> | |
</html></body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment