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; | |
websocket '/echo' => sub { | |
my $self = shift; | |
$self->on(message => sub { | |
my ($self, $message) = @_; | |
$self->send("echo: $message"); | |
}); | |
}; |
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; | |
get '/title' => sub { | |
my $self = shift; | |
my $url = $self->param('url'); | |
$self->render(text => | |
$self->client->get($url)->success->dom->at('title')->text); | |
}; | |
app->start; |
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; | |
my $feed = 'http://blog.kraih.com/rss.xml'; | |
get '/blog/atom/perl/atom.xml' => sub { | |
my $self = shift; | |
$self->ua->max_redirects(5)->get($feed => sub { | |
$self->render(text => shift->res->body, format => 'rss'); | |
}); | |
}; |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
# Use bundled libraries | |
use FindBin; | |
use lib "$FindBin::Bin/../lib"; | |
# Mamma Mia! The cruel meatball of war has rolled onto our laps and ruined |
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
{hypnotoad => {listen => ['https://*:443?cert=erver.crt&key=server.key&ca=ca.crt']}} |
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 Mojo::UserAgent; | |
my $ua = Mojo::UserAgent->new(cert => 'client.crt', key => 'client.key'); | |
$ua->get('https://localhost/s3cret.html')->res->dom('#launch-codes > li')->each(sub { | |
print shift->text; | |
}); |
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
% ./myapp.pl daemon --listen https://*:443?cert=server.crt&key=server.key&ca=ca.crt |
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
@@ cookies.html.ep | |
% title 'We love cookies!'; | |
% layout 'tasty'; | |
Mmmmmmmm... chocolate chips! | |
@@ layouts/tasty.html.ep | |
<!doctype html><html> | |
<head><title><%= title %></title></head> | |
<body><%= content %></body> | |
</html> |
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
% mojo generate lite_app | |
[exist] /Users/sri | |
[write] /Users/sri/myapp.pl | |
[chmod] myapp.pl 744 | |
% plackup myapp.pl | |
HTTP::Server::PSGI: Accepting connections at http://0:5000/ |
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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Plack::Builder; | |
get '/welcome' => sub { | |
my $self = shift; | |
$self->render(text => 'Hello Mojo!'); | |
}; |
OlderNewer