Litestar Python
Litestar साठी Python स्निपेट, जो /pixel.gif वरच्या रिक्वेस्टना empty 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