The WSGI has two sides: the "server" or "gateway" side (often the web server like Apache, Nignx), and the "application" or "framework" side (the python script itself). To process a WSGI request, the server side executes the application and provides environment information and a callback function to the application side. The application processes the request, and returns the response to the server side using the callback function it was provided.
The So-called WSGI middleware sits in the middle of the server and application thus implements both sides of the API. The server after receiving request from a client forwards it to he middleware using WSGI, when after processing it sends a request to another WSGI script/application who's response is forwarded to the client via the middleware and ultimately via the server. There maybe multiple middlewares, thus forming a stack of WSGI compliant applications.
A "middleware" component can perform such functions as:
Routing a request to different application objects based on the target URL, after changing the environment variables accordingly.
Allowing multiple applications or frameworks to run side-by-side in the same process
Load balancing and remote processing, by forwarding requests and responses over a network
Perform content postprocessing, such as applying XSLT stylesheets
No comments:
Post a Comment