emptygif
语言: 简体中文

所有语言和框架

Fresh TypeScript

一个用于 Fresh 的 TypeScript 代码片段,以空 GIF 响应对 /pixel.gif 的请求,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 示例