emptygif
Ngôn ngữ: Tiếng Việt

Tất cả ngôn ngữ và framework

AWS Lambda (Node.js) JavaScript

Đoạn mã JavaScript cho AWS Lambda (Node.js), trả lời các yêu cầu tới /pixel.gif bằng GIF rỗng, được giải mã một lần khi khởi động.

AWS Lambda (Node.js) JavaScript

Tệp
index.mjs
// index.mjs - behind an API Gateway HTTP API route "GET /pixel.gif" or a function URL.
// Binary bodies travel base64-encoded, so the GIF stays in base64 here.
const GIF_BASE64 = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';

export const handler = async () => ({
  statusCode: 200,
  headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
  body: GIF_BASE64,
  isBase64Encoded: true,
});

Chúng tôi đã chạy đoạn mã này và so sánh các byte nó trả về.

Kiểm tra

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

Trang chính thức: AWS Lambda (Node.js)

Thêm với JavaScript