emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

Starlette Python

Starlette માટે Python સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Starlette Python

ઇન્સ્ટૉલ
pip install starlette uvicorn
ફાઇલ
app.py
ચલાવો
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)])

અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.

ચકાસો

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

સત્તાવાર સાઇટ: Starlette

Python માં વધુ