emptygif
ಭಾಷೆ: ಕನ್ನಡ

ಎಲ್ಲಾ ಭಾಷೆಗಳು ಮತ್ತು ಫ್ರೇಮ್‌ವರ್ಕ್‌ಗಳು

Deno Deploy (deno serve) TypeScript

/pixel.gif ಗೆ ಬರುವ ವಿನಂತಿಗಳಿಗೆ ಖಾಲಿ GIF ನೊಂದಿಗೆ ಉತ್ತರಿಸುವ, Deno Deploy (deno serve) ಗಾಗಿ ಒಂದು TypeScript ಸ್ನಿಪೆಟ್; GIF ಅನ್ನು ಆರಂಭದಲ್ಲಿ ಒಮ್ಮೆ ಮಾತ್ರ ಡಿಕೋಡ್ ಮಾಡಲಾಗುತ್ತದೆ.

Deno Deploy (deno serve) TypeScript

ಫೈಲ್
main.ts
ರನ್
deno serve --port 8080 main.ts
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;

ನಾವು ಈ ಸ್ನಿಪೆಟ್ ಅನ್ನು ರನ್ ಮಾಡಿ, ಅದು ಹಿಂತಿರುಗಿಸಿದ ಬೈಟ್‌ಗಳನ್ನು ಹೋಲಿಸಿದ್ದೇವೆ.

ಪರಿಶೀಲಿಸಿ

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

ಅಧಿಕೃತ ಸೈಟ್: Deno Deploy (deno serve)

TypeScript ನಲ್ಲಿ ಇನ್ನಷ್ಟು