emptygif
Language: English

All languages and frameworks

Google Cloud Run functions (Python) Python

A Python snippet for Google Cloud Run functions (Python) that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Google Cloud Run functions (Python) Python

Install
pip install functions-framework
File
main.py
Run
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"}

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Google Cloud Run functions (Python)

More in Python