emptygif
Basa: Basa Jawa

Kabeh basa lan framework

Google Cloud Run functions (Python) Python

Snippet Python kanggo Google Cloud Run functions (Python) sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

Google Cloud Run functions (Python) Python

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

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: Google Cloud Run functions (Python)

Liyane ing Python