emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Google Cloud Run functions (Python) Python

Ein Python-Snippet für Google Cloud Run functions (Python), das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Google Cloud Run functions (Python) Python

Installieren
pip install functions-framework
Datei
main.py
Ausführen
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"}

Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.

Prüfen

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

Offizielle Website: Google Cloud Run functions (Python)

Mehr in Python