Litestar Python
Litestar için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir Python örneği.
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])
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
Python için daha fazlası
- 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