emptygif
Idioma: Português

Todas as linguagens e frameworks

Bottle Python

Um snippet em Python para Bottle que responde às requisições para /pixel.gif com o GIF vazio, decodificado uma única vez na inicialização.

Bottle Python

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

Executamos este snippet e comparamos os bytes que ele retornou.

Verificar

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

Site oficial: Bottle

Mais em Python