emptygif
Harshe: Hausa

Duk harsuna da frameworks

Starlette Python

Snippet na Python don Starlette da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Starlette Python

Girkawa
pip install starlette uvicorn
Fayil
app.py
Gudanar
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)])

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: Starlette

Ƙari a Python