Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Python wsgi protocol

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 12 Anzeige
Anzeige

Weitere Verwandte Inhalte

Diashows für Sie (20)

Ähnlich wie Python wsgi protocol (20)

Anzeige

Aktuellste (20)

Python wsgi protocol

  1. 1. Python WSGI Protocol -Presented By Rinkal Modi Divya Ahuja Krisha Jain
  2. 2. Outlines  Why WSGI?  Introduction  What is WSGI?  Middleware  Requests and Responses  Example  Advantages
  3. 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. 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. 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. 6. What is WSGI? • HTTP = Hyper Text Transfer Protocol • WSGI = Web Server Gateway Interface
  7. 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. 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.
  9. 9. Requests and Responses
  10. 10. Example #web_application.py from wsgiref.simple_server import make_server def application(environ, start_response): path = environ.get('PATH_INFO') if path == '/': response_body = "Index" else: response_body = "Hello" status = "200 OK" response_headers = [("Content-Length", str(len(response_body)))] start_response(status, response_headers) return [response_body] httpd = make_server( '127.0.0.1', 8051, application) httpd.serve_forever()
  11. 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.
  12. 12. Thank You..

×