emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Cloudflare Pages Functions TypeScript

Cloudflare Pages Functions için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir TypeScript örneği.

Cloudflare Pages Functions TypeScript

Dosya
pixel.ts
Çalıştır
npx wrangler pages dev public
// functions/pixel.gif.ts  (the file path is the route)
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

export const onRequestGet: PagesFunction = () =>
  new Response(GIF, {
    headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
  });

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: Cloudflare Pages Functions

TypeScript için daha fazlası