emptygif
Harshe: Hausa

Duk harsuna da frameworks

Microdot (CPython and MicroPython) Python

Snippet na Python don Microdot (CPython and MicroPython) da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Microdot (CPython and MicroPython) Python

Girkawa
pip install microdot
Fayil
app.py
Gudanar
python app.py
import binascii  # available on MicroPython as well as CPython

from microdot import Microdot

GIF = binascii.a2b_base64("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

app = Microdot()


@app.get("/pixel.gif")
async def pixel(request):
    return GIF, 200, {"Content-Type": "image/gif", "Cache-Control": "no-store"}


app.run(port=8080)

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

Duba shi

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

Shafin hukuma: Microdot (CPython and MicroPython)

Ƙari a Python