logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Mojo - Web development toolkit

Description

       A powerful web development toolkit, with all the basic tools and helpers needed to write simple web
       applications and higher level web frameworks, such as Mojolicious. Some of the most commonly used tools
       are Mojo::UserAgent, Mojo::DOM, Mojo::JSON, Mojo::Server::Daemon, Mojo::Server::Prefork, Mojo::IOLoop and
       Mojo::Template.

       See Mojolicious::Guides for more!

Name

       Mojo - Web development toolkit

See Also

       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.

perl v5.40.0                                       2024-12-07                                          Mojo(3pm)

Synopsis

         # HTTP/WebSocket user agent
         use Mojo::UserAgent;
         my $ua = Mojo::UserAgent->new;
         say $ua->get('www.mojolicious.org')->result->headers->server;

         # HTML/XML DOM parser with CSS selectors
         use Mojo::DOM;
         my $dom = Mojo::DOM->new('<div><b>Hello Mojo!</b></div>');
         say $dom->at('div > b')->text;

         # Perl-ish templates
         use Mojo::Template;
         my $mt = Mojo::Template->new(vars => 1);
         say $mt->render('Hello <%= $what %>!', {what => 'Mojo'});

         # HTTP/WebSocket server
         use Mojo::Server::Daemon;
         my $daemon = Mojo::Server::Daemon->new(listen => ['http://*:8080']);
         $daemon->unsubscribe('request')->on(request => sub ($daemon, $tx) {
           $tx->res->code(200);
           $tx->res->body('Hello Mojo!');
           $tx->resume;
         });
         $daemon->run;

         # Event loop
         use Mojo::IOLoop;
         for my $seconds (1 .. 5) {
           Mojo::IOLoop->timer($seconds => sub { say $seconds });
         }
         Mojo::IOLoop->start;

See Also