Learn MOJOLICIOUS with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Mojolicious Simple Web App
use Mojolicious::Lite;
# Homepage route
get '/' => sub {
my $c = shift;
$c->render(text => 'Hello, Mojolicious!');
};
# JSON API route
get '/api/data' => sub {
my $c = shift;
$c->render(json => { items => [1, 2, 3] });
};
app->start;
Demonstrates a simple Mojolicious app with routes for a homepage and a JSON API endpoint.