emptygif
Idioma: Español

Todos los lenguajes y frameworks

Google Cloud Run functions (Python) Python

Un fragmento en Python para Google Cloud Run functions (Python) que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.

Google Cloud Run functions (Python) Python

Instalar
pip install functions-framework
Archivo
main.py
Ejecutar
functions-framework --target=pixel --port=8080
import base64

import functions_framework

GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")


@functions_framework.http
def pixel(request):
    if request.path != "/pixel.gif":
        return "Not Found", 404
    return GIF, 200, {"Content-Type": "image/gif", "Cache-Control": "no-store"}

Ejecutamos este fragmento y comparamos los bytes que devolvió.

Comprobar

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

Sitio oficial: Google Cloud Run functions (Python)

Más en Python