emptygif
Language: English

All languages and frameworks

Mojolicious Perl

A Perl snippet for Mojolicious that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Mojolicious Perl

Install
cpanm Mojolicious
File
app.pl
Run
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;

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Mojolicious

More in Perl