emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Fastify JavaScript

Ein JavaScript-Snippet für Fastify, das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Fastify JavaScript

Installieren
npm i fastify
Datei
server.mjs
Ausführen
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' });

Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.

Prüfen

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

Offizielle Website: Fastify

Mehr in JavaScript