Lahat ng language at framework
Falcon Python
Isang Python snippet para sa Falcon na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.
Falcon Python
import base64
import falcon.asgi
GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
class PixelResource:
async def on_get(self, req: falcon.asgi.Request, resp: falcon.asgi.Response) -> None:
resp.content_type = "image/gif"
resp.cache_control = ["no-store"]
resp.data = GIF
app = falcon.asgi.App()
app.add_route("/pixel.gif", PixelResource())
Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.
Suriin
curl -sI http://localhost:8080/pixel.gif
Iba pa sa Python
- AWS Lambda (Python)
- Google Cloud Run functions (Python)
- FastAPI
- Litestar
- Starlette
- Django
- Flask
- aiohttp
- Sanic
- Quart
- 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