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

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

Encore.ts TypeScript

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

Encore.ts TypeScript

इंस्टॉल
encore app create --example=ts/hello-world
फ़ाइल
pixel.ts
चलाएँ
encore run
// pixel/pixel.ts  (inside a service directory with an encore.service.ts)
import { api } from 'encore.dev/api';

const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');

// A raw endpoint gets Node's req/res, so the bytes are written untouched.
export const pixel = api.raw(
  { expose: true, method: 'GET', path: '/pixel.gif' },
  async (req, resp) => {
    resp.writeHead(200, {
      'Content-Type': 'image/gif',
      'Content-Length': GIF.length,
      'Cache-Control': 'no-store',
    });
    resp.end(GIF);
  },
);

फ़्रेमवर्क के मौजूदा डॉक्यूमेंटेशन से मिलाकर जाँचा गया।

जाँचें

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

आधिकारिक साइट: Encore.ts

TypeScript में और