📜 ⬆️ ⬇️

Mojolicious :: Lite

Sebastian Riedel never ceases to amaze, he announced Mojolicious :: Lite last Saturday. This is really cool, I haven’t seen such a thing in a pearl yet, really a “quick start”:

put the module:
  cpan Mojolicious :: Lite 

create a script:
  ! / usr / bin / perl

 use strict;
 use warnings;

 use Mojolicious :: Lite;

 get '/' => sub {
     my $ self = shift;
     $ self-> render (text => 'It works!');
 };

 shagadelic; 
run:
  perl ./mojolitetest.pl daemon 
that's all, open it in the browser http: // localhost: 3000 / and enjoy it)

but that's not all that I wanted to show, of course, you can use templates and right in the same script:
  ! / usr / bin / perl

 use strict;
 use warnings;

 use Mojolicious :: Lite;

 get '/' => sub {
     my $ self = shift;
     $ self-> render (text => 'It works!');
 };
 get '/ foo' => sub {
     my $ self = shift;
     $ self-> render (template => 'foo');
 };

 shagadelic;

 __DATA__
 @@ foo.html.eplite
 It's from template! 
run the script and at http: // localhost: 3000 / foo we see:
“It's from template!”
')
more information on the module page

Source: https://habr.com/ru/post/65662/


All Articles