use Mojolicious::Lite; use DBI; use Mojolicious::Plugin::ReCAPTCHAv2; plugin 'ReCAPTCHAv2' => { sitekey => '... your value received from google', secret => '... idem', api_timeout => 120, }; get '/surv' => sub { my $c = shift; $c->stash( captcha => $c->app->recaptcha_get_html ); }; post '/surv' => sub { my $c = shift; my $app = $c->app; if ( $app->recaptcha_verify ) { $app->log->debug( "Hi there " . $c->param('first name') ); } else { if ( my $err = $app->recaptcha_get_errors ) { foreach my $e ( @{$err} ) { $app->log->debug( "Error code : " . $e ); } } else { $app->log->debug("could be a bot here"); } } }; app->start; __DATA__ @@ surv.html.ep %= form_for surv => (method => 'POST') => begin %= text_field 'first_name' <%= $captcha %> %= submit_button %en