Your framework provides an easy way, like ./manage.py runserver
, to start a server and serve requests. But things start getting trickier in production as you can't use runserver
in production and you need to use a WSGI compliant server. And you don't understand WSGI properly.
In this talk, I intend to lessen(hopefully remove) the confusion surrounding WSGI.
We will start with a discussion of WSGI. It involves:
Our objective will be writing a web application which works with few different urls. Serving these requests require a web server. We will use a WSGI compliant server provided as part of Python standard library. And then we will interface our application with this web server.
All this will be pure Python and we will not use any framework.
We will replace default Python server with Gunicorn(a WSGI compliant web server). This will help establish that we can easily switch between web servers as long as the server is WSGI compliant, and it won't require any change to web application code.