2. Outlines
Why WSGI?
Introduction
What is WSGI?
Middleware
Requests and Responses
Example
Advantages
3. Why WSGI?
• WSGI servers are designed to handle many requests
concurrently.
• WSGI speeds up Python web application development because
you only need to know basic things about WSGI.
• WSGI gives you the flexibility of changing web stack components
for alternatives without changing the application that runs with
WSGI.
4. Introduction
• The Web Server Gateway Interface (WSGI) is a specification for
simple and universal interface between web servers and web
applications for the python.
• The WSGI has two sides:
1. server/gateway
2. Application/framework.
• To process a WSGI request, the server side executes the
application and provides environment information and a callback
function to the application side.
5. Continue…
• The application processes the request, returning the response to
the server side using the callback function.
• Between the server and application, there may be a WSGI
middleware, which implements both sides of API.
• The server receives a request from a client and forwards it to the
middleware.
• After processing, it sends a request to the application.
• The applications response is forwarded by the middleware to the
server and ultimately to the client.
6. What is WSGI?
• HTTP = Hyper Text Transfer Protocol
• WSGI = Web Server Gateway Interface
7. Middleware
• Middleware : A component that play both sides.
• A single object may play the role of server with respect to some
applications, while also acting as an application with respect to
some servers.
• Thus it is transparent to both the server/gateway and the
application/framework sides of interface.
8. Continue…
• FUNCTIONS :
i. Routing request to different applications based on target
URL.
ii. Allowing multiple applications/framework to run side by
side in same process.
iii. Load balancing and remote processing, by forwarding
requests and responses over a network.
iv. Perform content post processing, such as applying XSL style
sheets.
11. Advantages
• Applications can be run by different users.
• No need to restart the web server to upgrade code.
• Applications with different versions of python.
• No shared libraries conflicts.