1Mojo(3)               User Contributed Perl Documentation              Mojo(3)
2
3
4

NAME

6       Mojo - Web development toolkit
7

SYNOPSIS

9         # HTTP/WebSocket user agent
10         use Mojo::UserAgent;
11         my $ua = Mojo::UserAgent->new;
12         say $ua->get('www.mojolicious.org')->result->headers->server;
13
14         # HTML/XML DOM parser with CSS selectors
15         use Mojo::DOM;
16         my $dom = Mojo::DOM->new('<div><b>Hello Mojo!</b></div>');
17         say $dom->at('div > b')->text;
18
19         # Perl-ish templates
20         use Mojo::Template;
21         my $mt = Mojo::Template->new(vars => 1);
22         say $mt->render('Hello <%= $what %>!', {what => 'Mojo'});
23
24         # HTTP/WebSocket server
25         use Mojo::Server::Daemon;
26         my $daemon = Mojo::Server::Daemon->new(listen => ['http://*:8080']);
27         $daemon->unsubscribe('request')->on(request => sub ($daemon, $tx) {
28           $tx->res->code(200);
29           $tx->res->body('Hello Mojo!');
30           $tx->resume;
31         });
32         $daemon->run;
33
34         # Event loop
35         use Mojo::IOLoop;
36         for my $seconds (1 .. 5) {
37           Mojo::IOLoop->timer($seconds => sub { say $seconds });
38         }
39         Mojo::IOLoop->start;
40

DESCRIPTION

42       A powerful web development toolkit, with all the basic tools and
43       helpers needed to write simple web applications and higher level web
44       frameworks, such as Mojolicious. Some of the most commonly used tools
45       are Mojo::UserAgent, Mojo::DOM, Mojo::JSON, Mojo::Server::Daemon,
46       Mojo::Server::Prefork, Mojo::IOLoop and Mojo::Template.
47
48       See Mojolicious::Guides for more!
49

SEE ALSO

51       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
52
53
54
55perl v5.36.0                      2023-01-20                           Mojo(3)
Impressum