emptygif
Harshe: Hausa

Duk harsuna da frameworks

BlackSheep Python

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

BlackSheep Python

Girkawa
pip install blacksheep uvicorn
Fayil
app.py
Gudanar
uvicorn app:app --port 8080
import base64

from blacksheep import Application, Content, Response, get

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

app = Application()


@get("/pixel.gif")
async def pixel() -> Response:
    return Response(200, [(b"Cache-Control", b"no-store")], Content(b"image/gif", GIF))

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

Duba shi

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

Shafin hukuma: BlackSheep

Ƙari a Python