emptygif
Bahasa: Bahasa Indonesia

Semua bahasa dan framework

Fresh TypeScript

Snippet TypeScript untuk Fresh yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat startup.

Fresh TypeScript

Instal
deno run -Ar jsr:@fresh/init
File
main.ts
Jalankan
deno task dev
// main.ts - a programmatic route (Fresh 2)
import { App } from 'fresh';
import { decodeBase64 } from 'jsr:@std/encoding/base64';

const GIF = decodeBase64('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

export const app = new App()
  .get('/pixel.gif', () =>
    new Response(GIF, {
      headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
    }))
  .fsRoutes();

Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.

Periksa

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

Situs resmi: Fresh

Lainnya dalam TypeScript