emptygif
Wika: Filipino

Lahat ng language at framework

Fastify JavaScript

Isang JavaScript snippet para sa Fastify na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

Fastify JavaScript

I-install
npm i fastify
File
server.mjs
Patakbuhin
node server.mjs
import Fastify from 'fastify';

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

const app = Fastify();

app.get('/pixel.gif', (request, reply) => {
  reply
    .type('image/gif')
    .header('Cache-Control', 'no-store')
    .send(GIF);
});

await app.listen({ port: 8080, host: '0.0.0.0' });

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: Fastify

Iba pa sa JavaScript