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
use warnings; | |
use strict; | |
use MCE::Loop; | |
use MCE::Shared; | |
MCE::Loop::init { | |
user_begin => sub{ | |
require FOO::DB; FOO::DB->import("get_bar"); | |
}, | |
max_workers => 8, |
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; | |
any '/' => sub { | |
my $c = shift; | |
} => 'index' ; | |
websocket '/uploads' => sub { | |
my $c = shift; | |
$c->on( json => sub { |
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; | |
# jump off from example by Joel Berger in Intro to Mojolicious | |
any '/' => 'index'; | |
websocket '/data' => sub { | |
my $self = shift; | |
my ($pi,$runs,$new_runs) = (0,0,500000); | |
my $timer = Mojo::IOLoop->recurring( 0.1 => sub { |
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; | |
any '/' => sub { | |
my $self = shift; | |
$self->render( 'index', rows => [ [] ] ); | |
}; | |
# setup websocket message handler |
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
use Mojolicious::Lite; | |
plugin CGI => [ "/cgi-bin/script" => "cgi-bin/forms/word_binner.pl " ]; | |
# Upload form in DATA section | |
get '/' => 'form'; | |
# Multipart upload handler | |
post '/upload' => sub { |
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
use Mojolicious::Lite; | |
plugin CGI => [ "/working" => "./cgi-bin/basic.pl" ]; | |
plugin CGI => { | |
route => '/works/too', | |
run => sub { | |
print "HTTP/1.1 200 OK\r\n"; | |
print "Content-Type: text/html; charset=ISO-8859-1\r\n"; | |
print "\r\n"; | |
print "<body><p>Hi!\n"; | |
}, |
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 DateTime; | |
use Mojolicious::Lite; | |
get '/' => 'index'; | |
get '/service/datetime' => sub { | |
my $self = shift; | |
my $dt = DateTime->now; |