emptygif
Lingua: Italiano

Tutti i linguaggi e framework

BlackSheep Python

Uno snippet Python per BlackSheep che risponde alle richieste a /pixel.gif con la GIF vuota, decodificata una sola volta all'avvio.

BlackSheep Python

Installa
pip install blacksheep uvicorn
File
app.py
Esegui
uvicorn app:app --port 8080
import base64

from blacksheep import Application, Content, Response, get

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

app = Application()


@get("/pixel.gif")
async def pixel() -> Response:
    return Response(200, [(b"Cache-Control", b"no-store")], Content(b"image/gif", GIF))

Abbiamo eseguito questo snippet e confrontato i byte che ha restituito.

Verifica

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

Sito ufficiale: BlackSheep

Altro in Python