emptygif
Harshe: Hausa

Duk harsuna da frameworks

SvelteKit TypeScript

Snippet na TypeScript don SvelteKit da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

SvelteKit TypeScript

Girkawa
npx sv create
Fayil
+server.ts
Gudanar
npm run dev
// src/routes/pixel.gif/+server.ts
import type { RequestHandler } from './$types';

const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

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

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: SvelteKit

Ƙari a TypeScript