emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Bottle Python

Ein Python-Snippet für Bottle, das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Bottle Python

Installieren
pip install bottle
Datei
app.py
Ausführen
python app.py
import base64

from bottle import Bottle, response

GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

app = Bottle()


@app.get("/pixel.gif")
def pixel():
    response.content_type = "image/gif"
    response.set_header("Cache-Control", "no-store")
    return GIF


if __name__ == "__main__":
    app.run(host="0.0.0.0", 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: Bottle

Mehr in Python