A Byte of WSGI
If you have ever used some python frameworks like tornado, flask, you may hear about WSGI. But what’s this?
WSGI means Web Server Gateway Interface. What it is NOT:a server, a python module, a framework, an API or any kind of software. What it is: What it is: an interface specification by which server and application communicate. WSGI is just a kind of protocol who makes web app and web server communicate friendly.
A simple WSGI application(meaning WSGI compliant) may look like this:
It’s a callable and takes two parameters environ and start_respone.
environ is a dictionary containing environment variables in CGI.
start_respone is a callable taking two required parameters
status(200 OK) and
And a simple WSGI server may look like this:
Both app and server above are WSGI compliant and the two function just explain how the python frameworks work.
If you want to dive into WSGI, go to PEP3333 :).