emptygif
Harshe: Hausa

Duk harsuna da frameworks

Google Cloud Run functions (Python) Python

Snippet na Python don Google Cloud Run functions (Python) da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Google Cloud Run functions (Python) Python

Girkawa
pip install functions-framework
Fayil
main.py
Gudanar
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"}

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: Google Cloud Run functions (Python)

Ƙari a Python