emptygif
Harshe: Hausa

Duk harsuna da frameworks

Fastify JavaScript

Snippet na JavaScript don Fastify da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Fastify JavaScript

Girkawa
npm i fastify
Fayil
server.mjs
Gudanar
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' });

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: Fastify

Ƙari a JavaScript