Litestar Python
Litestar کے لیے Python کا اسنیپٹ جو /pixel.gif کی درخواستوں کا جواب خالی GIF سے دیتا ہے، جسے اسٹارٹ اپ پر ایک بار ڈیکوڈ کیا جاتا ہے۔
Litestar Python
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])
ہم نے یہ اسنیپٹ چلایا اور اس کی لوٹائی ہوئی بائٹس کا موازنہ کیا۔
جانچیں
curl -sI http://localhost:8080/pixel.gif
Python میں مزید
- AWS Lambda (Python)
- Google Cloud Run functions (Python)
- FastAPI
- Starlette
- Django
- Flask
- aiohttp
- Sanic
- Quart
- Falcon
- Robyn
- BlackSheep
- Tornado
- Bottle
- Pyramid
- Microdot (CPython and MicroPython)
- Raw ASGI (Uvicorn, Granian, Hypercorn)
- Raw WSGI (Gunicorn, uWSGI, mod_wsgi)
- Python standard library (http.server)
- Python one-liner