emptygif
Wika: Filipino

Lahat ng language at framework

Cloudflare Pages Functions TypeScript

Isang TypeScript snippet para sa Cloudflare Pages Functions na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

Cloudflare Pages Functions TypeScript

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

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: Cloudflare Pages Functions

Iba pa sa TypeScript