emptygif
Basa: Basa Jawa

Kabeh basa lan framework

Google Cloud Run functions (Node.js) JavaScript

Snippet JavaScript kanggo Google Cloud Run functions (Node.js) sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

Google Cloud Run functions (Node.js) JavaScript

Instal
npm i @google-cloud/functions-framework
File
index.mjs
Lakokake
npx functions-framework --target=pixel --port=8080
import * as functions from '@google-cloud/functions-framework';

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

functions.http('pixel', (req, res) => {
  if (req.path !== '/pixel.gif') {
    res.sendStatus(404);
    return;
  }
  res.set('Cache-Control', 'no-store').type('gif').send(GIF);
});

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: Google Cloud Run functions (Node.js)

Liyane ing JavaScript