emptygif
Lingua: Italiano

Tutti i linguaggi e framework

Microdot (CPython and MicroPython) Python

Uno snippet Python per Microdot (CPython and MicroPython) che risponde alle richieste a /pixel.gif con la GIF vuota, decodificata una sola volta all'avvio.

Microdot (CPython and MicroPython) Python

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

Abbiamo eseguito questo snippet e confrontato i byte che ha restituito.

Verifica

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

Sito ufficiale: Microdot (CPython and MicroPython)

Altro in Python