Cloudflare Pages Functions TypeScript
Cloudflare Pages Functions के लिए TypeScript स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।
Cloudflare Pages Functions TypeScript
// 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