Ave
I'm trying to render an image (with its name) via a Mojolicious::Lite app. Note that a full path to the file is given and putting a link in "public" isn't very appealing. No doubt someone will say don't do that it's a security problem - but the app is only for my own use.
The app:
#!/usr/local/bin/perl
use warnings;
use Data::Dumper;
use Mojolicious::Lite -signatures;
use Mojolicious::Static;
# Let's just say all we know about the image is
my $directory = 'c:/xyzzy/test/'; # some arbitrary directory
my $name = 'TEST';
my $extension = '.jpg';
# And we want to create the page as in "picture.html.ep"
get '/picture' => sub($c) {
#my $static = Mojolicious::Static->new;
$c->stash(name=>$name,extension=>$extension);
# The following generates
#" Can't locate object method "static" via package "Mojolicious::C
+ontroller""
warn Data::Dumper->new([\$c->static->paths],[qw(path)])->Dump(),q{
+ };
push @{$c->static->paths}, $directory;
warn Data::Dumper->new([\$c->static->paths],[qw(path)])->Dump(),q{
+ };
};
app->start;
__DATA__
@@ picture.html.ep
<!DOCTYPE HTML>
<html>
<body>
<h2><%== $directory.$name.$extension %></h2>
<img src="<%== $name.$extension %>" alt="FAILED!" />
</body>
</html>
So how does one supplement/modify/alter the path that Mojolicious::Lite uses to serve public files?