emptygif
Langue: Français

Tous les langages et frameworks

BlackSheep Python

Un extrait Python pour BlackSheep qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

BlackSheep Python

Installer
pip install blacksheep uvicorn
Fichier
app.py
Lancer
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))

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

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

Site officiel: BlackSheep

Autres extraits en Python