Home ¦ Posts ¦ Books ¦ Articles ¦ Talks ¦ Notes

Python + Web applications

Python Web Application Cookbook

Custom Middleware

Middleware, a.k.a "How do I do X for every request and do Y for every response"?

WSGI middleware

  • http://wsgi.readthedocs.io/en/latest/libraries.html

aiohttp

  • http://aiohttp.readthedocs.io/en/stable/web.html#middlewares
  • Example middleware: http://codevoyagers.com/2016/09/01/from-flask-to-aiohttp/#whythecontext

Third-party packages

Django

  • https://docs.djangoproject.com/en/1.10/topics/http/middleware/
  • http://www.effectivedjango.com/middleware.html

Third-party packages

Flask

  • http://flask.pocoo.org/docs/0.11/patterns/deferredcallbacks/
  • Flask's after_request(), before_request() including blueprint specific methods
  • Example of implementing a middleware: http://steinn.org/post/flask-statsd/

Third-party packages

Miscellaneous

Telemetry

Logging

Deployment

Health checks

Service discovery

Load Balancing

Distributed Tracing

Asynchronous Operations

Circuit breaking

Microservices

RPCs

© Amit Saha. Built using Pelican. Customised theme based on the one by Giulio Fidente on github.