Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mojolicious::Lite - inserting picture question

When I run this script and open http://my_server/picture I get instead the picture the logo-string.

#!/usr/local/bin/perl
use warnings;
use 5.014;
use Mojolicious::Lite;

get '/picture' => sub {
    shift->render();
};

app->start;

__DATA__
@@ picture.html.ep
<!DOCTYPE HTML>
<html>
<body>
<p>Hello</p>
<img src="/absolute/path/TEST.jpg" alt="logo" />
<p>World</p>
</body>
</html>

When I open this HTML-piece as normal HTML-file I get the picture.

What is the right way, to insert a picture with Mojolicious::Lite?

like image 328
sid_com Avatar asked Dec 06 '25 01:12

sid_com


1 Answers

The public directory is intended for static data. Just create it next to your script and put the image in. When development server with default settings is running, you can access it on url:

http://localhost:3000/TEST.jpg

So your template can contain:

<img src="/TEST.jpg" />
like image 185
bvr Avatar answered Dec 07 '25 15:12

bvr