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 मध्ये आणखी