emptygif
Langue: Français

Tous les langages et frameworks

Azure Functions (Node.js v4 model) JavaScript

Un extrait JavaScript pour Azure Functions (Node.js v4 model) qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

Azure Functions (Node.js v4 model) JavaScript

Installer
npm i @azure/functions
Fichier
pixel.js
Lancer
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',
    },
  }),
});

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

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

Site officiel: Azure Functions (Node.js v4 model)

Autres extraits en JavaScript