emptygif
Harshe: Hausa

Duk harsuna da frameworks

Google Cloud Run functions (Node.js) JavaScript

Snippet na JavaScript don Google Cloud Run functions (Node.js) da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Google Cloud Run functions (Node.js) JavaScript

Girkawa
npm i @google-cloud/functions-framework
Fayil
index.mjs
Gudanar
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);
});

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: Google Cloud Run functions (Node.js)

Ƙari a JavaScript