emptygif
Harshe: Hausa

Duk harsuna da frameworks

Cloudflare Pages Functions TypeScript

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

Cloudflare Pages Functions TypeScript

Fayil
pixel.ts
Gudanar
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' },
  });

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

Duba shi

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

Shafin hukuma: Cloudflare Pages Functions

Ƙari a TypeScript