emptygif
Idioma: Español

Todos los lenguajes y frameworks

Bottle Python

Un fragmento en Python para Bottle que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.

Bottle Python

Instalar
pip install bottle
Archivo
app.py
Ejecutar
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)

Ejecutamos este fragmento y comparamos los bytes que devolvió.

Comprobar

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

Sitio oficial: Bottle

Más en Python