emptygif
زبان: اردو

تمام زبانیں اور فریم ورکس

Azure Functions (Node.js v4 model) JavaScript

Azure Functions (Node.js v4 model) کے لیے JavaScript کا اسنیپٹ جو /pixel.gif کی درخواستوں کا جواب خالی GIF سے دیتا ہے، جسے اسٹارٹ اپ پر ایک بار ڈیکوڈ کیا جاتا ہے۔

Azure Functions (Node.js v4 model) JavaScript

انسٹال
npm i @azure/functions
فائل
pixel.js
چلائیں
func start
// src/functions/pixel.js
import { app } from '@azure/functions';

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

app.http('pixel', {
  methods: ['GET'],
  authLevel: 'anonymous',
  // Routes have no leading slash and sit under the "api" prefix unless
  // extensions.http.routePrefix is set to "" in host.json.
  route: '/pixel.gif'.slice(1),
  handler: async () => ({
    body: GIF,
    headers: {
      'Content-Type': 'image/gif',
      'Content-Length': String(GIF.length),
      'Cache-Control': 'no-store',
    },
  }),
});

ہم نے یہ اسنیپٹ چلایا اور اس کی لوٹائی ہوئی بائٹس کا موازنہ کیا۔

جانچیں

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

آفیشل سائٹ: Azure Functions (Node.js v4 model)

JavaScript میں مزید