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

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

Firebase Cloud Functions + Hosting JavaScript

Firebase Cloud Functions + Hosting માટે JavaScript સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Firebase Cloud Functions + Hosting JavaScript

ઇન્સ્ટૉલ
npm i firebase-functions firebase-admin
ફાઇલ
index.js
ચલાવો
firebase emulators:start
// functions/index.js - and in firebase.json:
//   "hosting": { "rewrites": [{ "source": "/pixel.gif", "function": { "functionId": "pixel" } }] }
import { onRequest } from 'firebase-functions/https';

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

export const pixel = onRequest((req, res) => {
  res.set('Cache-Control', 'no-store').type('gif').send(GIF);
});

અમે આ સ્નિપેટને કમ્પાઇલ અથવા ટાઇપ-ચેક કર્યો.

ચકાસો

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

સત્તાવાર સાઇટ: Firebase Cloud Functions + Hosting

JavaScript માં વધુ