Implementing shared functionality using Middleware
summary
Shows concrete code and interoperable patterns: Flask uses before_request/after_request decorators, Django supports class and function middleware with ordering controlled in settings, and FastAPI exposes add_middleware for async ASGI classes. Demonstrates a working wrapping technique that turns WSGI/ASGI apps into framework-agnostic middleware, uses an OpenTelemetry WSGI middleware example, and shows embedding a Flask app inside Django and caching middleware for FastAPI so functionality actually runs and returns responses.
AI-written summary · about
chapters (14)
- 0:00Start
- 1:58Flask middleware
- 3:40Multiple middleware in Flask
- 7:55Activate middleware
- 9:25Recap
- 14:00Open Telemetry WSGI Middleware
- 16:30Middleware for wrapping another WSGI application
- 16:54Wrapper Middleware
- 19:17A FastAPI application
- 19:37Using ASGI Middleware
- 20:52Adding the Middleware
- 22:40Integrate a WSGI application
- 23:19WSGIMiddleware Implementation
- 23:52Key takeaways
related talks
26mInside web framework: intro to the ASGI spec, middleware and apps
26mUsing Django as a Micro-Framework: Hacking on the HTTP handlers..
31mHey, Python-Web-Community! What's going on?
18mFrom WSGI to ASGI - Django 3.0
31mInside ASGI The Engine Behind Modern Python Web Frameworks
24mA Brief History of Python Web Frameworks
34mIntro to FastAPI
33mNo Holds Barred Web Framework Battle
