emptygif
భాష: తెలుగు

అన్ని భాషలు, ఫ్రేమ్‌వర్క్‌లు

Cloudflare Pages Functions TypeScript

/pixel.gif కు వచ్చే రిక్వెస్ట్‌లకు empty GIF తో జవాబిచ్చే, Cloudflare Pages Functions కోసం TypeScript స్నిపెట్. 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 లో మరిన్ని