File: README.pod

package info (click to toggle)
libmojolicious-perl 2.98%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,968 kB
  • sloc: perl: 10,178; sh: 48; makefile: 8
file content (138 lines) | stat: -rw-r--r-- 3,356 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

=pod

Back in the early days of the web, many people learned Perl because of a
wonderful Perl library called L<CGI>. It was simple enough to get started
without knowing much about the language and powerful enough to keep you going,
learning by doing was much fun. While most of the techniques used are outdated
now, the idea behind it is not. L<Mojolicious> is a new attempt at
implementing this idea using state of the art technology.

=head2 Features

=over 2

=item *

An amazing real-time web framework supporting a simplified single file mode
through L<Mojolicious::Lite>.

=over 2

Powerful out of the box with RESTful routes, plugins, Perl-ish templates,
session management, signed cookies, testing framework, static file server,
I18N, first class unicode support and much more for you to discover.

=back

=item *

Very clean, portable and Object Oriented pure Perl API without any hidden
magic and no requirements besides Perl 5.10.1 (although 5.12+ is recommended,
and optional CPAN modules will be used to provide advanced functionality if
they are installed).

=item *

Full stack HTTP 1.1 and WebSocket client/server implementation with IPv6, TLS,
IDNA, Comet (long polling), chunking and multipart support.

=item *

Built-in non-blocking I/O web server supporting libev and hot deployment,
perfect for embedding.

=item *

Automatic CGI and L<PSGI> detection.

=item *

JSON and HTML5/XML parser with CSS3 selector support.

=item *

Fresh code based upon years of experience developing L<Catalyst>.

=back

=head2 Installation

All you need is a oneliner, it takes less than a minute.

  $ curl get.mojolicio.us | sh

=head2 Getting Started

These three lines are a whole web application.

  use Mojolicious::Lite;

  get '/' => {text => 'Hello World!'};

  app->start;

To run this example with the built-in development web server just put the code
into a file and start it with C<morbo>.

  $ morbo hello.pl
  Server available at http://127.0.0.1:3000.

  $ curl http://127.0.0.1:3000/
  Hello World!

=head2 Duct tape for the HTML5 web

Web development for humans, making hard things possible and everything fun.

  use Mojolicious::Lite;

  # Simple plain text response
  get '/' => {text => 'Hello World!'};

  # Route associating "/time" with template in DATA section
  get '/time' => 'clock';

  # RESTful web service with JSON and text representation
  get '/list/:offset' => sub {
    my $self    = shift;
    my $numbers = [0 .. $self->param('offset')];
    $self->respond_to(
      json => {json => $numbers},
      txt  => {text => join(',', @$numbers)}
    );
  };

  # Scrape information from remote sites
  post '/title' => sub {
    my $self = shift;
    my $url  = $self->param('url') || 'http://mojolicio.us';
    $self->render_text(
      $self->ua->get($url)->res->dom->html->head->title->text);
  };

  # WebSocket echo service
  websocket '/echo' => sub {
    my $self = shift;
    $self->on(message => sub {
      my ($self, $message) = @_;
      $self->send("echo: $message");
    });
  };

  app->start;
  __DATA__

  @@ clock.html.ep
  % use Time::Piece;
  % my $now = localtime;
  The time is <%= $now->hms %>.

Single file prototypes like this one can easily grow into well-structured
applications.

=head2 Want to know more?

Take a look at our excellent documentation at L<http://mojolicio.us/perldoc>!

=cut