Skip to content

Instantly share code, notes, and snippets.

@sergeyromanov
Created November 23, 2011 19:42
Show Gist options
  • Save sergeyromanov/1389681 to your computer and use it in GitHub Desktop.
Save sergeyromanov/1389681 to your computer and use it in GitHub Desktop.
Test reCAPTCHA plugin for Mojolicious
#!/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