emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Hono on Deno TypeScript

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

Hono on Deno TypeScript

Installieren
deno add jsr:@hono/hono
Datei
server.ts
Ausführen
deno run --allow-net server.ts
import { Hono } from 'jsr:@hono/hono';
import { decodeBase64 } from 'jsr:@std/encoding/base64';

const GIF = decodeBase64('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

const app = new Hono();

app.get('/pixel.gif', (c) =>
  c.body(GIF, 200, {
    'Content-Type': 'image/gif',
    'Cache-Control': 'no-store',
  }),
);

Deno.serve({ port: 8080 }, app.fetch);

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

Prüfen

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

Offizielle Website: Hono on Deno

Mehr in TypeScript