emptygif
Language: English

All languages and frameworks

Express JavaScript

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

Express JavaScript

Install
npm i express
File
server.mjs
Run
node server.mjs
import express from 'express';

const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');

const app = express();

app.get('/pixel.gif', (req, res) => {
  res.set('Cache-Control', 'no-store');
  res.type('gif').send(GIF);
});

app.listen(8080);

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Express

More in JavaScript