emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

Google Cloud Run functions (Node.js) JavaScript

Google Cloud Run functions (Node.js) માટે JavaScript સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Google Cloud Run functions (Node.js) JavaScript

ઇન્સ્ટૉલ
npm i @google-cloud/functions-framework
ફાઇલ
index.mjs
ચલાવો
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);
});

અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.

ચકાસો

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

સત્તાવાર સાઇટ: Google Cloud Run functions (Node.js)

JavaScript માં વધુ