emptygif
ভাষা: বাংলা

সব ভাষা ও ফ্রেমওয়ার্ক

Cloudflare Pages Functions TypeScript

Cloudflare Pages Functions-এর জন্য একটি TypeScript স্নিপেট, যা /pixel.gif-এ আসা রিকোয়েস্টের উত্তরে empty 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-এ আরও