GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mojo(3) User Contributed Perl Documentation Mojo(3)

Mojo - Web development toolkit

  # 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;

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!

Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
2021-12-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.