emptygif
Langue: Français

Tous les langages et frameworks

AWS Lambda (Python) Python

Un extrait Python pour AWS Lambda (Python) qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

AWS Lambda (Python) Python

Fichier
lambda_function.py
# lambda_function.py - behind an API Gateway HTTP API route "GET /pixel.gif" or a function URL.
# Binary bodies travel base64-encoded, so the GIF stays in base64 here.
GIF_BASE64 = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="


def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "headers": {"Content-Type": "image/gif", "Cache-Control": "no-store"},
        "body": GIF_BASE64,
        "isBase64Encoded": True,
    }

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: AWS Lambda (Python)

Autres extraits en Python