Looking for a diagram to explain WSGI

As I gained nothing by looking at Ian's fancy tubes I decided to draw a diagram myself. I hope it will help someone understand how WSGI flow works. As long as you have suggestions how to make it better I'm open to modify it. It was created with LUCIDCHART webapp. The original diagram you can find here and the high quality PNG is here.

WSGI Flow


I don't know if I can provide the answer you are looking for but the diagram you linked to shows more than just wsgi. The wsgi layer ends at the second line on the diagram. After that it's application specific.

WSGI is more an interface definition or contract that boils down to somehow you provide a function which takes a dictionary (environ) which represents the contents of the current request. and a function to call when you are ready to start the response(start_response).

The start_response method that you call needs a HTTP status code('200 OK') and a list of HTTP headers([('content-type', 'text/html')]).

def say_hello(envron={},start_response):
    start_response('200 OK', [('content-type', 'text/html')])
    return ["Hello from WSGI"]

Linking up your web server to your wsgi app is specific to your webserver I think and information on how the webserver arrives at the environ dictionary and a callback for your code to call is the webserver magic that you probably don't need to be concerned about. And as long as you obey the protocol, the webserver doesn't need to care how you arrived at your list of output that constitutes your response from your application.

The Paste documentation helped me a LOT. You may find it useful. BTW, Paste is a bunch of useful things that help you utilize WSGI.And the docs are very good for understanding how to use WSGI and by extension Paste.

I know you asked for a diagram sorry. :(


I like the diagram from Ian Bicking's WSGI - A Series of Tubes.