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
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