emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Microdot (CPython and MicroPython) Python

Ein Python-Snippet für Microdot (CPython and MicroPython), das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Microdot (CPython and MicroPython) Python

Installieren
pip install microdot
Datei
app.py
Ausführen
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)

Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.

Prüfen

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

Offizielle Website: Microdot (CPython and MicroPython)

Mehr in Python