emptygif
Wika: Filipino

Lahat ng language at framework

Microdot (CPython and MicroPython) Python

Isang Python snippet para sa Microdot (CPython and MicroPython) na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

Microdot (CPython and MicroPython) Python

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

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: Microdot (CPython and MicroPython)

Iba pa sa Python