emptygif
言語: 日本語

すべての言語・フレームワーク

Fresh TypeScript

/pixel.gif へのリクエストに空の GIF を返す、Fresh 用の TypeScript スニペット。GIF は起動時に一度だけデコードします。

Fresh TypeScript

インストール
deno run -Ar jsr:@fresh/init
ファイル
main.ts
実行
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();

このスニペットは実行し、返されたバイト列を照合しました。

確認

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

公式サイト: Fresh

TypeScript の他の例