emptygif
Idioma: Português

Todas as linguagens e frameworks

Google Cloud Run functions (Python) Python

Um snippet em Python para Google Cloud Run functions (Python) que responde às requisições para /pixel.gif com o GIF vazio, decodificado uma única vez na inicialização.

Google Cloud Run functions (Python) Python

Instalar
pip install functions-framework
Arquivo
main.py
Executar
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"}

Executamos este snippet e comparamos os bytes que ele retornou.

Verificar

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

Site oficial: Google Cloud Run functions (Python)

Mais em Python