Created
September 23, 2016 12:12
-
-
Save kraih/88ccb2448e1df38481da2af71c04e896 to your computer and use it in GitHub Desktop.
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
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