emptygif
Lugha: Kiswahili

Lugha na framework zote

Next.js (App Router) TypeScript

Kipande cha TypeScript kwa Next.js (App Router) kinachojibu maombi ya /pixel.gif kwa empty GIF, ambayo husimbuliwa (decode) mara moja programu inapoanza.

Next.js (App Router) TypeScript

Sakinisha
npx create-next-app@latest
Faili
route.ts
Endesha
npm run dev
// app/pixel.gif/route.ts
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

export function GET() {
  return new Response(GIF, {
    headers: {
      'Content-Type': 'image/gif',
      'Content-Length': String(GIF.length),
      'Cache-Control': 'no-store',
    },
  });
}

Tuliendesha kipande hiki na kulinganisha baiti kilizorudisha.

Kagua

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

Tovuti rasmi: Next.js (App Router)

Zaidi katika TypeScript