emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

Mojolicious Perl

Snippet Perl untuk Mojolicious yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.

Mojolicious Perl

Instal
cpanm Mojolicious
File
app.pl
Jalankan
perl app.pl daemon -l http://*:8080
use Mojolicious::Lite -signatures;
use Mojo::Util qw(b64_decode);

my $gif = b64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

get '/pixel.gif' => sub ($c) {
  $c->res->headers->cache_control('no-store');
  $c->render(data => $gif, format => 'gif');
};

app->start;

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

curl -sI http://localhost:8080/pixel.gif

Situs resmi: Mojolicious

Lainnya dalam Perl