Lahat ng language at framework
Deno Deploy (deno serve) TypeScript
Isang TypeScript snippet para sa Deno Deploy (deno serve) na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.
Deno Deploy (deno serve) TypeScript
import { decodeBase64 } from 'jsr:@std/encoding/base64';
const GIF = decodeBase64('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
export default {
fetch(req) {
if (new URL(req.url).pathname !== '/pixel.gif') {
return new Response('Not Found', { status: 404 });
}
return new Response(GIF, {
headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
});
},
} satisfies Deno.ServeDefaultExport;
Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.
Suriin
curl -sI http://localhost:8080/pixel.gif
Opisyal na site: Deno Deploy (deno serve)