emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Starlette Python

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

Starlette Python

Kurulum
pip install starlette uvicorn
Dosya
app.py
Çalıştır
uvicorn app:app --port 8080
import base64

from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import Response
from starlette.routing import Route

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


async def pixel(request: Request) -> Response:
    return Response(GIF, media_type="image/gif", headers={"Cache-Control": "no-store"})


app = Starlette(routes=[Route("/pixel.gif", 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: Starlette

Python için daha fazlası