emptygif
Wika: Filipino

Lahat ng language at framework

Google Cloud Run functions (Python) Python

Isang Python snippet para sa Google Cloud Run functions (Python) na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

Google Cloud Run functions (Python) Python

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

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: Google Cloud Run functions (Python)

Iba pa sa Python