Minimal [Mojolicious::Lite][] app:
```perl
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
get '/:foo' => sub ($c) {
my $foo = $c->param('foo');
$c->render(text => "Hello from $foo.");
};
app->start;
```
Getting parameters (in a controller sub, `$c` is the controller object):
```perl
# Get/Set
my $foo = $c->param('foo')
$c->param(foo => 'whatever');
# Multiple values
my @foo = $c->every_param('foo');
my $all_params_hash = $c->req->params; # All params
my $foo = $c->req->query_params->param('foo'); # GET
my $foo = $c->req->body_params->param('foo'); # POST
my $foo = $c->req->param('foo'); # GET & POST
my $foo = $c->req->upload('foo'); # file uploads
```
Rendering stuff:
```perl
$c->render(text => "OK\n");
$c->render(json => {});
$c->render(data => $bytes);
$c->render(template => 'index');
# set for download with specific filename
$c->res->headers->content_disposition('attachment; filename=bar.pdf;');
$c->render(
data => $datastring,
format => 'pdf',
status => 201,
)
# nothing to render (more), just set the status
$c->rendered(204); # No content
```
[Embedded Perl][]:
```
<% Perl code %>
<%= Perl expression, replaced with XML escaped result %>
<%== Perl expression, replaced with result %>
<%# Comment, useful for debugging %>
<%% Replaced with "<%", useful for generating templates %>
% Perl code line, treated as "<% line =%>" (explained later)
%= Perl expression line, treated as "<%= line %>"
%== Perl expression line, treated as "<%== line %>"
%# Comment line, useful for debugging
%% Replaced with "%", useful for generating templates
```
HTML generation shortcuts are provided by [TagHelpers][]:
```
%= text_field 'first_name'
%= text_field first_name => 'Default'
%= text_field first_name => 'Default', class => 'user'
%= hidden_field foo => 'bar'
%= hidden_field foo => 'bar', id => 'bar'
%= submit_button
%= submit_button 'Ok!', id => 'foo'
```
Also:
- [CORS][]
- [Authentication][] (with [under][])
[Mojolicious::Lite]: https://metacpan.org/pod/Mojolicious::Lite
[Embedded Perl]: https://docs.mojolicious.org/Mojolicious/Guides/Rendering#Embedded-Perl
[TagHelpers]: https://docs.mojolicious.org/Mojolicious/Plugin/TagHelpers
[CORS]: https://etoobusy.polettix.it/2020/09/09/cors-quick-note/
[Authentication]: https://etoobusy.polettix.it/2021/06/07/mpa-example/
[under]: https://etoobusy.polettix.it/2021/06/08/mpa-under/