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 DateTime; | |
use Mojolicious::Lite; | |
get '/' => 'index'; | |
get '/service/datetime' => sub { | |
my $self = shift; | |
my $dt = DateTime->now; |
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/perl | |
use Mojolicious::Lite; | |
get '/' => { message => '' } => 'index'; | |
post '/' => sub { | |
my $self = shift; | |
# getting params | |
my $email = $self->param('email') || ''; |
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 EV; | |
use AnyEvent; | |
use AnyEvent::Util; | |
get '/' => sub { | |
my $self = shift; | |
# Run Perl oneliner in separate process and capture STDOUT | |
fork_call { |
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 strict; | |
use warnings; | |
use IO::Async::Channel; | |
use IO::Async::Loop; | |
use IO::Async::Routine; | |
my $loop = IO::Async::Loop->new(); | |
{ |
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
package PiffHop; | |
use strict; | |
use warnings; | |
use base 'Mojolicious'; | |
# This method will run once at server start | |
sub startup { | |
my $self = shift; |
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
package MyApp::Validation; | |
use Validation::Class; | |
use base 'Validation::Class'; | |
# a validation rule | |
field 'login' => { | |
label => 'user login', | |
error => 'login invalid', | |
validation => sub { |
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
package MyApp::Validation; | |
use Validation::Class; | |
use base 'Validation::Class'; | |
# a validation rule | |
field 'login' => { | |
label => 'user login', | |
error => 'login invalid', | |
validation => sub { |
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 common::sense; | |
use lib qw(../.. /tk/lib /tk/mojo2/lib); | |
use ojo; | |
use Util; | |
use Unicode::Normalize 'NFD'; | |
use Data::Dumper; | |
my $conf = { |
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 '/tasks' => sub { | |
my $self = shift; | |
$self->stash( | |
tasks => [ | |
map { [ split /\s+/ ] } | |
split /\n/, qx(ps axh -o comm,stat,\%cpu,nice,pid,rss,user) | |
] |
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; | |
get '/' => 'index'; | |
get '/ok' => 'index_ok'; | |
use Test::More; | |
plan tests => 6; |