emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

Fastify JavaScript

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

Fastify JavaScript

Instal
npm i fastify
File
server.mjs
Jalankan
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' });

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

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

Situs resmi: Fastify

Lainnya dalam JavaScript