Skip to content

Instantly share code, notes, and snippets.

@ology
Created August 8, 2023 13:22
Show Gist options
  • Save ology/42a133c1b8ddd953037b61eb550cc9e9 to your computer and use it in GitHub Desktop.
Save ology/42a133c1b8ddd953037b61eb550cc9e9 to your computer and use it in GitHub Desktop.
Can't get the /*img route to work - help?
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
use Mojo::File ();
get '/' => sub ($c) {
$c->render(template => 'index');
};
get '/album/*img' => sub ($c) {
my $file = $c->param('img');
warn __PACKAGE__,' L',__LINE__,' ',,"F: $file\n";
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
<h1>Welcome to the Mojolicious real-time web framework!</h1>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
.
├── route.pl
└── public
└── album
   └── 13-sided-tile.png
# /album/13-sided-tile.png is displayed in the browser but the '/album/*img' route is never called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment