emptygif
زبان: اردو

تمام زبانیں اور فریم ورکس

Cloudflare Pages Functions TypeScript

Cloudflare Pages Functions کے لیے TypeScript کا اسنیپٹ جو /pixel.gif کی درخواستوں کا جواب خالی GIF سے دیتا ہے، جسے اسٹارٹ اپ پر ایک بار ڈیکوڈ کیا جاتا ہے۔

Cloudflare Pages Functions TypeScript

فائل
pixel.ts
چلائیں
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' },
  });

ہم نے یہ اسنیپٹ چلایا اور اس کی لوٹائی ہوئی بائٹس کا موازنہ کیا۔

جانچیں

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

آفیشل سائٹ: Cloudflare Pages Functions

TypeScript میں مزید