Skip to content

Instantly share code, notes, and snippets.

@kraih
Created September 23, 2016 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kraih/88ccb2448e1df38481da2af71c04e896 to your computer and use it in GitHub Desktop.
Save kraih/88ccb2448e1df38481da2af71c04e896 to your computer and use it in GitHub Desktop.
use Mojolicious::Lite;
use Mojo::IOLoop;
sub fib { $_[0] < 2 ? 1 : fib($_[0] - 2) + fib($_[0] - 1) }
get '/fibonacci' => sub {
my $c = shift;
$c->inactivity_timeout(300);
Mojo::IOLoop->subprocess(
sub { fib(35) },
sub {
my ($subprocess, $err, $result) = @_;
$c->render(text => "The result of fib(35) is $result.");
}
);
};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment