emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Deno Deploy (deno serve) TypeScript

Deno Deploy (deno serve) için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir TypeScript örneği.

Deno Deploy (deno serve) TypeScript

Dosya
main.ts
Çalıştır
deno serve --port 8080 main.ts
import { decodeBase64 } from 'jsr:@std/encoding/base64';

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

export default {
  fetch(req) {
    if (new URL(req.url).pathname !== '/pixel.gif') {
      return new Response('Not Found', { status: 404 });
    }
    return new Response(GIF, {
      headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
    });
  },
} satisfies Deno.ServeDefaultExport;

Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.

Kontrol et

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

Resmî site: Deno Deploy (deno serve)

TypeScript için daha fazlası