emptygif
Langue: Français

Tous les langages et frameworks

Microdot (CPython and MicroPython) Python

Un extrait Python pour Microdot (CPython and MicroPython) qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

Microdot (CPython and MicroPython) Python

Installer
pip install microdot
Fichier
app.py
Lancer
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)

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

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

Site officiel: Microdot (CPython and MicroPython)

Autres extraits en Python