emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Litestar Python

Litestar için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir Python örneği.

Litestar Python

Kurulum
pip install "litestar[standard]"
Dosya
app.py
Çalıştır
litestar --app app:app run --port 8080
import base64

from litestar import Litestar, get
from litestar.datastructures import CacheControlHeader

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


@get(
    "/pixel.gif",
    media_type="image/gif",
    cache_control=CacheControlHeader(no_store=True),
    include_in_schema=False,
)
async def pixel() -> bytes:
    return GIF


app = Litestar([pixel])

Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.

Kontrol et

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

Resmî site: Litestar

Python için daha fazlası