Todas as linguagens e frameworks
Pyramid Python
Um snippet em Python para Pyramid que responde às requisições para /pixel.gif com o GIF vazio, decodificado uma única vez na inicialização.
Pyramid Python
import base64
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
GIF = base64.b64decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
def pixel(request):
return Response(body=GIF, content_type="image/gif", cache_control="no-store")
if __name__ == "__main__":
with Configurator() as config:
config.add_route("pixel", "/pixel.gif")
config.add_view(pixel, route_name="pixel", request_method="GET")
app = config.make_wsgi_app()
make_server("0.0.0.0", 8080, app).serve_forever()
Executamos este snippet e comparamos os bytes que ele retornou.
Verificar
curl -sI http://localhost:8080/pixel.gif
Mais em Python
- AWS Lambda (Python)
- Google Cloud Run functions (Python)
- FastAPI
- Litestar
- Starlette
- Django
- Flask
- aiohttp
- Sanic
- Quart
- Falcon
- Robyn
- BlackSheep
- Tornado
- Bottle
- Microdot (CPython and MicroPython)
- Raw ASGI (Uvicorn, Granian, Hypercorn)
- Raw WSGI (Gunicorn, uWSGI, mod_wsgi)
- Python standard library (http.server)
- Python one-liner