Mojolicious. Веб в коробке!
-
Upload
anatoly-sharifulin -
Category
Education
-
view
4.261 -
download
6
description
Transcript of Mojolicious. Веб в коробке!
![Page 1: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/1.jpg)
Mojolicious.Веб в коробке!
Анатолий Шарифулин
![Page 3: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/3.jpg)
Sebastian Riedelавтор Catalyst и Mojolicious
http://twitter.com/kraih
![Page 5: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/5.jpg)
Что такоеMojolicious?
![Page 6: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/6.jpg)
Что такое Mojolicious?• Pure Perl веб-фреймворк
• Без зависимостей (с версии Perl 5.8.1)
• Объектно-ориентированное API (без скрытой магии)
• Поддержка HTTP 1.1, WebSocket, IPv6, SSL, IDNA
• Поддержка CGI, FastCGI, PSGI, Daemon и Prefork
• Веб-фреймворки: Mojo, Mojolicious и Mojolicious::Lite
![Page 7: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/7.jpg)
«Fresh code,based upon years of expirience developing
Catalyst»
![Page 9: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/9.jpg)
Pure Perlвеб-фреймворк
![Page 10: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/10.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 11: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/11.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 12: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/12.jpg)
Mojo::BaseMinimal Base Class For Mojo Projects
![Page 13: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/13.jpg)
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }
![Page 14: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/14.jpg)
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }
![Page 15: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/15.jpg)
package App;use base ‘Mojo::Base’;
__PACKAGE__->attr(conf => sub { return do ‘conf/app.conf’;});__PACKAGE__->attr(db => sub { my $self = shift; return Util->db($self->conf->{'db'});});
sub dispatch { ... }
![Page 16: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/16.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 17: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/17.jpg)
Mojo::ByteStreamByteStream
![Page 18: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/18.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 19: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/19.jpg)
use Mojo::ByteStream 'b';my $s = b('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 20: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/20.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 21: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/21.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 22: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/22.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 23: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/23.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 24: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/24.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 25: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/25.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 26: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/26.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 27: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/27.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 28: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/28.jpg)
use Mojo::ByteStream;my $s = Mojo::ByteStream->new('foo_bar');
$s->camelize; $s->decamelize;$s->b64_encode; $s->b64_decode;$s->encode('utf8'); $s->decode('utf8');$s->html_escape; $s->html_unescape;$s->qp_encode; $s->qp_decode;$s->quote; $stream->unquote;$s->url_escape; $s->url_unescape;$s->xml_escape;$s->punycode_encode; $s->punycode_decode;
![Page 29: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/29.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 30: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/30.jpg)
Mojo::TemplatePerlish Templates!
![Page 31: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/31.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 32: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/32.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 33: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/33.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 34: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/34.jpg)
% my $count = 10 * 5;
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 35: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/35.jpg)
% use Foo::Bar;
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 36: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/36.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 37: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/37.jpg)
% my $list = $self->stash(‘list’);
<ul>% if (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 38: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/38.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 39: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/39.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 40: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/40.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%== $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 41: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/41.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= ucfirst $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 42: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/42.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 43: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/43.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} %> </li>% }</ul>
<p><%# comment %></p>
![Page 44: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/44.jpg)
% my $list = $self->stash(‘list’);
<ul>% for (@$list) { <li> <%= $_->{title} xx %> </li>% }</ul>
<p><%# comment %></p>
1 2 3 4 5 6 7 8 91011
![Page 45: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/45.jpg)
Bareword "xx" not allowed while "strict subs" in use at template line 6.
Сообщение об ошибке
![Page 46: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/46.jpg)
Простота PHP, мощь Perl
![Page 47: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/47.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 48: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/48.jpg)
Mojo::JSONMinimalistic JSON
![Page 49: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/49.jpg)
my $json = Mojo::JSON->new;
my $string = $json->encode({foo => ‘bar’});
my $hash = $json->decode(‘{"foo":"bar"}’);
![Page 50: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/50.jpg)
my $json = Mojo::JSON->new;
my $string = $json->encode({foo => ‘bar’});
my $hash = $json->decode(‘{"foo":"bar"}’);
![Page 51: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/51.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 52: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/52.jpg)
Mojo::LoaderClass loader: load, reload, search
![Page 53: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/53.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 54: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/54.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 55: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/55.jpg)
• Mojo::Base
• Mojo::ByteStream
• Mojo::Template, Mojo::JSON
• Mojo::Loader, Mojo::Log, Mojo::Path
• Mojo::URL, Mojo::Parameters, Mojo::Content
• Mojo::Message::Request, Mojo::Message::Response,Mojo::Headers, Mojo::Cookie, Mojo::Date
![Page 56: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/56.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 57: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/57.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 58: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/58.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 59: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/59.jpg)
Mojo::IOLoopMinimalistic Reactor For TCP Clients And Servers
![Page 60: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/60.jpg)
Mojo::IOLoopПоддержка IO::KQueue, IO::Epoll,IO::Socket::INET6 и IO::Socket::SSL
![Page 61: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/61.jpg)
my $loop = Mojo::IOLoop->new;
$loop->listen(port => 3000, cb => sub { my ($self, $id) = @_; $self->read_cb ($id => sub { ... });
$self->write_cb($id => sub { ... }););
my $id = $loop->connect(port => 3000, ...);
$loop->start; $loop->stop;
![Page 62: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/62.jpg)
my $loop = Mojo::IOLoop->new;
$loop->listen(port => 3000, cb => sub { my ($self, $id) = @_; $self->read_cb ($id => sub { ... });
$self->write_cb($id => sub { ... }););
my $id = $loop->connect(port => 3000, ...);
$loop->start; $loop->stop;
![Page 63: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/63.jpg)
my $loop = Mojo::IOLoop->new;
$loop->listen(port => 3000, cb => sub { my ($self, $id) = @_; $self->read_cb ($id => sub { ... });
$self->write_cb($id => sub { ... }););
my $id = $loop->connect(port => 3000, ...);
$loop->start; $loop->stop;
![Page 64: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/64.jpg)
my $loop = Mojo::IOLoop->new;
$loop->listen(port => 3000, cb => sub { my ($self, $id) = @_; $self->read_cb ($id => sub { ... });
$self->write_cb($id => sub { ... }););
my $id = $loop->connect(port => 3000, ...);
$loop->start; $loop->stop;
![Page 65: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/65.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 66: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/66.jpg)
Mojo::ClientAsync IO HTTP 1.1 And WebSocket Client
![Page 67: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/67.jpg)
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 68: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/68.jpg)
my $client = Mojo::Client->new;
$self->client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 69: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/69.jpg)
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 70: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/70.jpg)
my $client = Mojo::Client->new;
$client->head( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 71: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/71.jpg)
my $client = Mojo::Client->new;
$client->post( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 72: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/72.jpg)
my $client = Mojo::Client->new;
$client->put( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 73: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/73.jpg)
my $client = Mojo::Client->new;
$client->async->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 74: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/74.jpg)
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 75: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/75.jpg)
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 76: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/76.jpg)
my $client = Mojo::Client->new;
$client->get( ‘http://goo.gl’ => sub { my ($self, $tx) = @_; say $tx->res; })->process;
![Page 77: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/77.jpg)
my $client = Mojo::Client->new;
$client->get(‘http://goo.gl’)->res->code;
$client->get( 'http://search.twitter.com/trends.json')->success->json->{trends}->[0]->{name}
![Page 78: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/78.jpg)
my $client = Mojo::Client->new;
$client->get(‘http://goo.gl’)->res->code;
$client->get( 'http://search.twitter.com/trends.json')->success->json->{trends}->[0]->{name}
![Page 80: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/80.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 81: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/81.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 82: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/82.jpg)
• Mojo::Trasaction
• Mojo::IOLoop
• Mojo::Client, Mojo::Server
• Mojo::Server::CGI, Mojo::Server::FastCGI
• Mojo::Server::PSGI
• Mojo::Server::Daemon и ::Prefork
• Mojo::Command
• Mojo::Command::Generate и ~ Server
![Page 83: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/83.jpg)
Всё, что нужно – естьMojolicious – веб в коробке!
![Page 84: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/84.jpg)
Без зависимостейс версии Perl 5.8.1
![Page 85: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/85.jpg)
Mojo runtime
![Page 86: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/86.jpg)
Perl 5.005
![Page 87: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/87.jpg)
Perl 5.006002
![Page 88: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/88.jpg)
Perl 5.008001
![Page 89: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/89.jpg)
Perl 5.010
![Page 90: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/90.jpg)
Объектно-ориентированное
API
![Page 91: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/91.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 92: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/92.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 93: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/93.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 94: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/94.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 95: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/95.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 96: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/96.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 97: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/97.jpg)
use overload '""' => sub { shift->to_string },
fallback => 1;
![Page 98: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/98.jpg)
GET / HTTP/1.1Connection: keep-aliveAccept: text/html, application/xhtml, ....Accept-Charset: windows-1251, utf-8; ...Accept-Encoding: gzip,deflateAccept-Language: ru,en-us;q=0.7,en;q=0.3Host: localhost:3000User-Agent: Mozilla/5.0 (Macintosh; ...Content-Length: 0Keep-Alive: 300
![Page 99: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/99.jpg)
Поддержка HTTP 1.1клиент-сервер
![Page 100: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/100.jpg)
![Page 101: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/101.jpg)
Google Summer of Code 2009Pascal Gaudette
MojoX::UserAgent
![Page 102: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/102.jpg)
Поддержка WebSocketклиент-сервер
![Page 103: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/103.jpg)
Протокол WebSocketGoogle, Inc
16 декабря 2009 года
![Page 104: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/104.jpg)
use Mojolicious::Lite;
websocket ‘/echo’ => sub { my $self = shift; $self->receive_message(sub { my ($self, $msg) = @_; $self->send_massage("echo: $msg"); });};
app->start;
![Page 105: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/105.jpg)
use Mojolicious::Lite;
websocket ‘/echo’ => sub { my $self = shift; $self->receive_message(sub { my ($self, $msg) = @_; $self->send_massage("echo: $msg"); });};
app->start;
![Page 106: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/106.jpg)
Mojolicious WebSocket ExamplesИнтересный пример IRC-клиент
Github.com @xantus
![Page 107: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/107.jpg)
Google Summer of Code 2010Performance tuning
the http/websocket implementation
![Page 108: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/108.jpg)
Поддержка CGI, FastCGI, PSGI,
Daemon и Prefork
![Page 109: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/109.jpg)
script/mojolicious COMMAND [OPTIONS]script/mojolicious cgiscript/mojolicious fastcgiscript/mojolicious psgi script/mojolicious daemonscript/mojolicious daemon_prefork
![Page 110: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/110.jpg)
script/mojolicious COMMAND [OPTIONS]script/mojolicious cgiscript/mojolicious fastcgiscript/mojolicious psgi script/mojolicious daemonscript/mojolicious daemon_prefork
![Page 111: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/111.jpg)
PATH_INFO='/foo/bar' script/mojolicious cgi
Легко тестироватьМожно профилировать код, используя Devel::NYTProf
![Page 112: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/112.jpg)
script/mojolicious COMMAND [OPTIONS]script/mojolicious cgiscript/mojolicious fastcgiscript/mojolicious psgi script/mojolicious daemonscript/mojolicious daemon_prefork
![Page 113: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/113.jpg)
Mojo::Server::FCGIscript/mojolicious fcgiscript/mojolicious fcgi_prefork
![Page 114: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/114.jpg)
script/mojolicious COMMAND [OPTIONS]script/mojolicious cgiscript/mojolicious fastcgiscript/mojolicious psgi script/mojolicious daemonscript/mojolicious daemon_prefork
![Page 115: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/115.jpg)
script/mojolicious COMMAND [OPTIONS]script/mojolicious cgiscript/mojolicious fastcgiscript/mojolicious psgi script/mojolicious daemonscript/mojolicious daemon_prefork
![Page 116: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/116.jpg)
script/mojolicious daemon --reload
Приложение перезагружается перед запросом,если код был изменен
![Page 117: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/117.jpg)
Обработка сигнала USR1Для обновления кода приложения
![Page 118: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/118.jpg)
script/mojolicious COMMAND [OPTIONS]script/mojolicious cgiscript/mojolicious fastcgiscript/mojolicious psgi script/mojolicious daemonscript/mojolicious daemon_prefork
![Page 119: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/119.jpg)
Веб-фреймворки
![Page 120: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/120.jpg)
MojoBase framework
![Page 121: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/121.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 122: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/122.jpg)
package App;use base 'Mojo';sub handler { my ($self, $tx) = @_; warn $tx->req; warn $tx->req->url; $tx->res->headers ->content_type('text/plain'); $tx->res->body('РИТ++ 2010');}1;
![Page 123: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/123.jpg)
Генерацияmojo-приложения
![Page 124: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/124.jpg)
script/mojo generateapp App
[write ] app/script/app[chmod] app/script/app 744[write ] app/lib/App.pm[write ] app/t/basic.t[mkdir ] app/log
![Page 125: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/125.jpg)
script/app COMMAND [OPTIONS]script/app cgiscript/app fastcgiscript/app psgi script/app daemonscript/app daemon_prefork
![Page 126: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/126.jpg)
script/app COMMAND [OPTIONS]script/app getscript/app test
![Page 127: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/127.jpg)
MVC веб-фреймворки
![Page 128: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/128.jpg)
Mojolicioususe base 'Mojo';
![Page 129: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/129.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 130: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/130.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 131: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/131.jpg)
Mojolicious::ControllerController Base Class
![Page 132: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/132.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 133: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/133.jpg)
• render(controller => 'foo', action => 'bar')
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 134: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/134.jpg)
• render(template => 'foo/bar')
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 135: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/135.jpg)
• render('foo#bar')
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 136: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/136.jpg)
• render('foo#bar', format => 'html')
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 137: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/137.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 138: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/138.jpg)
• render
• render_text('РИТ++ 2010')
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 139: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/139.jpg)
• render
• render(text => 'РИТ++ 2010')
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 140: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/140.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 141: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/141.jpg)
• render
• render_text
• render_data('binary data')
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 142: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/142.jpg)
• render
• render_text
• render(data => 'binary data')
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 143: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/143.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 144: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/144.jpg)
• render
• render_text
• render_data
• render_json({foo => 'bar'})
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 145: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/145.jpg)
• render
• render_text
• render_data
• render(json => {foo => 'bar'})
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 146: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/146.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 147: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/147.jpg)
• render
• render_text
• render_data
• render_json
• render_static('img/logo.png')
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 148: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/148.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 149: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/149.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 150: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/150.jpg)
• render
• render_text
• render_data
• render_json
• render_static
• render_not_found / render_exception
• send_message / receive_message
• url_for / redirect_to
![Page 151: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/151.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 152: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/152.jpg)
Mojolicious::PluginsPlugins
![Page 153: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/153.jpg)
• AgentCondition
• Charset
• DefaultHelpers
• EplRenderer
• EpRenderer
• HeaderCondition
• I18n, JsonConfig, PoweredBy
• PodRenderer, RequestTimer
![Page 154: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/154.jpg)
• AgentCondition
• Charset
• DefaultHelpers
• EplRenderer
• EpRenderer
• HeaderCondition
• I18n, JsonConfig, PoweredBy
• PodRenderer, RequestTimer
![Page 155: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/155.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 156: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/156.jpg)
• Data::Dumper (Maxdepth: 2, Indent: 1, Terse: 1)
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 157: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/157.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 158: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/158.jpg)
• dumper
• $self->req->param( ... )
• stash
• layout
• include
• content
• extends
• url_for
![Page 159: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/159.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 160: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/160.jpg)
• dumper
• param
• $self->stash( ... )
• layout
• include
• content
• extends
• url_for
![Page 161: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/161.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 162: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/162.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 163: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/163.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 164: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/164.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 165: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/165.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• url_for
![Page 166: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/166.jpg)
• dumper
• param
• stash
• layout
• include
• content
• extends
• $self->url_for
![Page 167: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/167.jpg)
• AgentCondition
• Charset
• DefaultHelpers
• EplRenderer
• EpRenderer
• HeaderCondition
• I18n, JsonConfig, PoweredBy
• PodRenderer, RequestTimer
![Page 168: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/168.jpg)
EplRendererEmbed Perl Lite
![Page 169: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/169.jpg)
• расширение шаблонов .epl
• в начале каждого шаблона:% my $self = shift;
• $self->stash('foo')
![Page 170: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/170.jpg)
• AgentCondition
• Charset
• DefaultHelpers
• EplRenderer
• EpRenderer
• HeaderCondition
• I18n, JsonConfig, PoweredBy
• PodRenderer, RequestTimer
![Page 171: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/171.jpg)
EpRendererEmbed Perl
![Page 172: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/172.jpg)
• расширение шаблонов .ep
• кеширование шаблонов со stash-параметрами
• вместо $self->stash('foo') – $foo
• доступны все helpers:
% layout 'default';
% warn dumper $list;
• обработчик по умолчанию в mojolicious
![Page 173: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/173.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 174: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/174.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 175: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/175.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 176: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/176.jpg)
• Mojolicous::Controller
• Mojolicious::Plugins
• Mojolicious::Commands
• MojoX::Types
• MojoX::Session
• MojoX::Dispatcher, MojoX::Routes
![Page 177: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/177.jpg)
Генерацияmojolicious-приложения
![Page 178: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/178.jpg)
script/mojolicious generateapp App
[write ] app/script/app[chmod] app/script/app 744[write ] app/lib/App.pm[write ] app/lib/App/Example.pm[write ] app/t/basic.t[mkdir ] app/log
![Page 179: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/179.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to('example#welcome', id => 1);}
1;
![Page 180: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/180.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to('example#welcome', id => 1);}
1;
![Page 181: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/181.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to('example#welcome', id => 1);}
1;
![Page 182: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/182.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to('example#welcome', id => 1);}
1;
![Page 183: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/183.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to('example#welcome', id => 1);}
1;
![Page 184: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/184.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:id', id => qr/\d+/) ->to('example#welcome');}
1;
![Page 185: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/185.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; for ($r->bridge->to('auth#check) { $_->route('/admin')->to('admin#welcome'); }}
![Page 186: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/186.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; for ($r->bridge->to('auth#check) { $_->route('/admin')->to('admin#welcome'); }}
![Page 187: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/187.jpg)
package App;use base 'Mojolicious';
sub startup { my $self = shift; my $r = $self->routes; $r->route('/:controller/:action/:id') ->to('example#welcome', id => 1);}
1;
![Page 188: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/188.jpg)
script/mojolicious generateapp App
[write ] app/script/app[chmod] app/script/app 744[write ] app/lib/App.pm[write ] app/lib/App/Example.pm[write ] app/t/basic.t[mkdir ] app/log
![Page 189: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/189.jpg)
package App::Example;use base 'Mojolicious::Controller';
sub welcome { my $self = shift; warn $self->stash(‘id’); $self->render(message => 'РИТ++ 2010');}
1;
![Page 190: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/190.jpg)
package App::Example;use base 'Mojolicious::Controller';
sub welcome { my $self = shift; warn $self->stash(‘id’); $self->render(message => 'РИТ++ 2010');}
1;
![Page 191: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/191.jpg)
package App::Example;use base 'Mojolicious::Controller';
sub welcome { my $self = shift; warn $self->stash(‘id’); $self->render(message => 'РИТ++ 2010');}
1;
![Page 192: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/192.jpg)
script/mojolicious generateapp App
[mkdir] app/public[write ] app/templates/not_found.html.ep[write ] app/templates/exception.html.ep[write ] app/templates/layouts/default.html.ep[write ] app/templates/example/welcome.html.ep
![Page 193: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/193.jpg)
script/mojolicious generateapp App
[mkdir] app/public[write ] app/templates/not_found.html.ep[write ] app/templates/exception.html.ep[write ] app/templates/layouts/default.html.ep[write ] app/templates/example/welcome.html.ep
![Page 194: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/194.jpg)
script/mojolicious generateapp App
[mkdir] app/public[write ] app/templates/not_found.html.ep[write ] app/templates/exception.html.ep[write ] app/templates/layouts/default.html.ep[write ] app/templates/example/welcome.html.ep
![Page 195: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/195.jpg)
% layout 'default';
<h2><%= $message %></h2>
<a href="<%== url_for %>">click here</a>
![Page 196: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/196.jpg)
% layout 'default';
<h2><%= $message %></h2>
<a href="<%== url_for %>">click here</a>
![Page 197: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/197.jpg)
% layout 'default';
<h2><%= $self->stash('message') %></h2>
<a href="<%== url_for %>">click here</a>
![Page 198: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/198.jpg)
% layout 'default';
<h2><%= $message %></h2>
<a href="<%== url_for %>">click here</a>
![Page 199: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/199.jpg)
% layout 'default';
<h2><%= stash 'message' %></h2>
<a href="<%== url_for %>">click here</a>
![Page 200: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/200.jpg)
% layout 'default';
<h2><%= $message %></h2>
<a href="<%== url_for %>">click here</a>
![Page 201: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/201.jpg)
script/mojolicious generateapp App
[mkdir] app/public[write ] app/templates/not_found.html.ep[write ] app/templates/exception.html.ep[write ] app/templates/layouts/default.html.ep[write ] app/templates/example/welcome.html.ep
![Page 202: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/202.jpg)
<!doctype html><html> <head><title>Welcome</title></head> <body> <%== content %> </body></html>
![Page 203: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/203.jpg)
<!doctype html><html> <head><title>Welcome</title></head> <body> <%== content %> </body></html>
![Page 204: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/204.jpg)
script/mojolicious generateapp App
[mkdir] app/public[write ] app/templates/not_found.html.ep[write ] app/templates/exception.html.ep[write ] app/templates/layouts/default.html.ep[write ] app/templates/example/welcome.html.ep
![Page 205: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/205.jpg)
script/mojolicious generateapp App
[mkdir] app/public[write ] app/templates/not_found.html.ep[write ] app/templates/exception.html.ep[write ] app/templates/layouts/default.html.ep[write ] app/templates/example/welcome.html.ep
![Page 206: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/206.jpg)
Global symbol "$message2" requires explicit package name at (eval 280) line 2.
1: % layout 'default';2: <h2><%= $message2 %></h2>3: ...
{ 'status' => 500, 'message' => ‘РИТ++ 2010’, ...
![Page 207: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/207.jpg)
example/welcome.html.ep
Автоматическая генерация имени шаблона
![Page 208: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/208.jpg)
controller/action.format.handler
Автоматическая генерация имени шаблона
![Page 209: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/209.jpg)
example/welcome.html.ep
Автоматическая генерация имени шаблона
![Page 210: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/210.jpg)
example/welcome.xml.ep
Автоматическая генерация имени шаблона
![Page 211: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/211.jpg)
example/welcome.rss.ep
Автоматическая генерация имени шаблона
![Page 212: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/212.jpg)
example/welcome.json.ep
Автоматическая генерация имени шаблона
![Page 213: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/213.jpg)
example/welcome.html.ep
Автоматическая генерация имени шаблона
![Page 214: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/214.jpg)
example/welcome.html.epl
Автоматическая генерация имени шаблона
![Page 215: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/215.jpg)
example/welcome.html.tt
Автоматическая генерация имени шаблона
![Page 216: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/216.jpg)
example/welcome.html.cttp2 Автоматическая генерация имени шаблона
![Page 217: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/217.jpg)
script/app COMMAND [OPTIONS]script/app cgiscript/app fastcgiscript/app psgi script/app daemonscript/app daemon_prefork
![Page 218: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/218.jpg)
script/app COMMAND [OPTIONS]script/app getscript/app testscript/app routes
![Page 219: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/219.jpg)
Mojolicious::Liteuse base 'Mojolicious';
![Page 220: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/220.jpg)
script/mojolicious generatelite_app lite.pl
[write ] lite.pl[chmod] lite.pl 744
![Page 221: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/221.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 222: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/222.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 223: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/223.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 224: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/224.jpg)
use Mojolicious::Lite;
post '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 225: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/225.jpg)
use Mojolicious::Lite;
any '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 226: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/226.jpg)
use Mojolicious::Lite;
get '/' => (agent => qr/Firefox/) => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 227: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/227.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => {groovy => 42} => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 228: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/228.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => [groovy => qr/\d+/] => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 229: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/229.jpg)
use Mojolicious::Lite;ladder sub {}; # authget '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 230: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/230.jpg)
use Mojolicious::Lite;websocket '/echo' => sub { ... }; get '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 231: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/231.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};app->renderer->default_handler('epl');app->start;
![Page 232: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/232.jpg)
use Mojolicious::Lite;
get '/' => 'index';
get '/:groovy' => sub { my $self = shift; $self->render_text( $self->param('groovy') );};
app->start;
![Page 233: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/233.jpg)
__DATA__
@@ index.html.ep% layout 'funky';Yea baby!
@@ layouts/funky.html.ep<!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body></html>
![Page 234: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/234.jpg)
__DATA__
@@ index.html.ep% layout 'funky';Yea baby!
@@ layouts/funky.html.ep<!doctype html><html> <head><title>Funky!</title></head> <body><%== content %></body></html>
![Page 235: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/235.jpg)
lite.pl COMMAND [OPTIONS]
lite.pl cgilite.pl fastcgilite.pl psgilite.pl daemonlite.pl daemon_prefork
![Page 236: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/236.jpg)
lite.pl COMMAND [OPTIONS]
lite.pl testlite.pl getlite.pl routeslite.pl inflate
![Page 237: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/237.jpg)
«Making hard things possible and everything fun!»
Девиз Mojolicious
![Page 238: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/238.jpg)
«Viva la revolution!»
Девиз Mojolicious #2
![Page 239: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/239.jpg)
«Duct tape for the HTML5 web»
Девиз Mojolicious #3
![Page 240: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/240.jpg)
Mojolicious-модули на CPAN• Mojolicious
• Mojo::Server::FCGI
• AnyEvent::Mojo
• Apache::Mojo
Apache2::Mojo
• Catalyst::Engine::MojoSquatting::On::Mojo
• MojoX::Routes::AsGraph
• MojoX::Log::*
• MojoX::Renderer::*
• TT
• CTTP2, HTP
• XSLT
![Page 241: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/241.jpg)
Mojolicious-модули на CPAN• Mojolicious
• Mojo::Server::FCGI
• AnyEvent::Mojo
• Apache::Mojo
Apache2::Mojo
• Catalyst::Engine::MojoSquatting::On::Mojo
• MojoX::Routes::AsGraph
• MojoX::Log::*
• MojoX::Renderer::*
• TT
• CTTP2, HTP
• XSLT
![Page 242: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/242.jpg)
Mojolicious-модули на CPAN• Mojolicious
• Mojo::Server::FCGI
• AnyEvent::Mojo
• Apache::Mojo
Apache2::Mojo
• Catalyst::Engine::MojoSquatting::On::Mojo
• MojoX::Routes::AsGraph
• MojoX::Log::*
• MojoX::Renderer::*
• TT
• CTTP2, HTP
• XSLT
![Page 243: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/243.jpg)
Mojolicious::Lite vs.
DancerСоревнование
![Page 244: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/244.jpg)
Стабильная версия, совместимость?
![Page 245: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/245.jpg)
Обратная совместимость не гарантируется :)
До первой стабильной версии
![Page 246: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/246.jpg)
Mojolicious 0.999925Последняя версия доступна на github.com
![Page 247: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/247.jpg)
Документация
• Пока не очень, зато очень хороший фидбек :) • Mojolicious::Lite и Mojolicious::Guides
• Mojolicious Handbook на github.com @kvorg
• Mojolicious FAQ на github.com @vti
![Page 248: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/248.jpg)
Полезная информация• http://mojolicious.org
• irc://irc.perl.org/#mojo
• http://groups.google.com/group/mojolicious
• Github: kraih, vti, xantus
• Twitter: @kraih, @vtivti, @sharifulin
• Juick: @vti, @sharifulin
![Page 249: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/249.jpg)
«Особая разновидность современного программиста – программист, изучающий
фреймворки»
![Page 250: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/250.jpg)
«Каждый программист должен сделать 3 вещи: фреймворк, шаблонизатор и событийную машину»
![Page 251: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/251.jpg)
use Mojoliciousor die;
![Page 252: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/252.jpg)
Viva la revolution!
![Page 253: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/253.jpg)
use Perlor die;
![Page 254: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/254.jpg)
JFDI
![Page 255: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/255.jpg)
any ‘/questions’ => sub { shift->render( answer => ‘sharifulin’, ); };
![Page 256: Mojolicious. Веб в коробке!](https://reader034.fdocuments.net/reader034/viewer/2022051109/54877e6cb4af9f6e0d8b547a/html5/thumbnails/256.jpg)
Спасибо за внимание!Это 256й слайдАнатолий Шарифулин