emptygif
भाषा: हिन्दी

सभी भाषाएँ और फ़्रेमवर्क

Oak TypeScript

Oak के लिए TypeScript स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।

Oak TypeScript

फ़ाइल
server.ts
चलाएँ
deno run --allow-net server.ts
import { Application, Router } from 'jsr:@oak/oak';
import { decodeBase64 } from 'jsr:@std/encoding/base64';

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

const router = new Router();
router.get('/pixel.gif', (ctx) => {
  ctx.response.type = 'image/gif';
  ctx.response.headers.set('Cache-Control', 'no-store');
  ctx.response.body = GIF;
});

const app = new Application();
app.use(router.routes());
await app.listen({ port: 8080 });

हमने यह स्निपेट चलाया और इसके लौटाए बाइट्स की तुलना की।

जाँचें

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

आधिकारिक साइट: Oak

TypeScript में और