emptygif
Language: English

All languages and frameworks

Microdot (CPython and MicroPython) Python

A Python snippet for Microdot (CPython and MicroPython) that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Microdot (CPython and MicroPython) Python

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

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Microdot (CPython and MicroPython)

More in Python