ಎಲ್ಲಾ ಭಾಷೆಗಳು ಮತ್ತು ಫ್ರೇಮ್ವರ್ಕ್ಗಳು
Pyramid Python
/pixel.gif ಗೆ ಬರುವ ವಿನಂತಿಗಳಿಗೆ ಖಾಲಿ GIF ನೊಂದಿಗೆ ಉತ್ತರಿಸುವ, Pyramid ಗಾಗಿ ಒಂದು Python ಸ್ನಿಪೆಟ್; GIF ಅನ್ನು ಆರಂಭದಲ್ಲಿ ಒಮ್ಮೆ ಮಾತ್ರ ಡಿಕೋಡ್ ಮಾಡಲಾಗುತ್ತದೆ.
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()
ನಾವು ಈ ಸ್ನಿಪೆಟ್ ಅನ್ನು ರನ್ ಮಾಡಿ, ಅದು ಹಿಂತಿರುಗಿಸಿದ ಬೈಟ್ಗಳನ್ನು ಹೋಲಿಸಿದ್ದೇವೆ.
ಪರಿಶೀಲಿಸಿ
curl -sI http://localhost:8080/pixel.gif
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