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 में और