emptygif
Harshe: Hausa

Duk harsuna da frameworks

Sanic Python

Snippet na Python don Sanic da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Sanic Python

Girkawa
pip install sanic
Fayil
server.py
Gudanar
sanic server:app --port 8080
import base64

from sanic import Sanic
from sanic.response import raw

GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

app = Sanic("pixel")


@app.get("/pixel.gif")
async def pixel(request):
    return raw(GIF, content_type="image/gif", headers={"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: Sanic

Ƙari a Python