Created
May 1, 2012 12:54
-
-
Save Akron/2567746 to your computer and use it in GitHub Desktop.
Hynotoad Example
This file contains 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/env perl | |
use Mojolicious::Lite; | |
our $counter = 0; | |
app->secret('kashkgfsjgnscjzgang'); | |
app->config({ | |
hypnotoad => { | |
listen => ['http://*:8765'], | |
workers => 5 | |
} | |
}); | |
get '/' => sub { | |
my $c = shift; | |
$c->render( | |
template => 'index', | |
counter => $counter++, | |
); | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<?xml version="1.0" encoding="utf-8" standalone="yes"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head><title>Welcome</title></head> | |
<body> | |
<h1>Welcome</h1> | |
<p>This is perl version: <%= $] %> running as a service.</p> | |
<p>Counter: <%= $counter %></p> | |
<p>Process: <%= $$ %></p> | |
% my $started = stash('mojo.started'); | |
% my $elapsed = sprintf '%f', Time::HiRes::tv_interval($started, [Time::HiRes::gettimeofday()]); | |
<p>Elapsed: <%= $elapsed %></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment