emptygif
Language: English

All languages and frameworks

BlackSheep Python

A Python snippet for BlackSheep that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

BlackSheep Python

Install
pip install blacksheep uvicorn
File
app.py
Run
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))

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: BlackSheep

More in Python