We cannot deny the fact that we live in the world of internet. Every day we come across multiple websites.

Today, if you want to communicate with some other person, you will use some language like English, Hindi or French which has some standard protocols. Similarly, if two computers want to communicate with each other over the internet, there should be some standard protocol, and that standard protocol is called “HyperText Transfer Protocol (HTTP)”.

So, the HTTP mentioned in the sample URL above in this blog is a communication protocol used to sent and receive webpages and other data files on the internet. When a user enters a web URL, an HTTP request that is sent by the browser and an HTTP response received from our application server have a definite format.

Today, most of the websites are dynamic in nature i.e. they are not based on files in the file system, but rather on programs which are run by the web server whenever a request comes in. These programs generate the content (through some calculation, logic, database etc) that is returned to the user. So, every application needs a web server that can interact with your code as well as with the outside world of HTTP. And, if your application is written in python, then all you need is a WSGI server for this purpose.

A Web Server Gateway Interface (WSGI) is a simple calling convention for web servers to forward request to web application or framework written in Python programming language.

A WSGI server implements the web server side of WSGI interface for running python web application. There are many WSGI servers in the market today like uWSGI, mod-WSGI, Green Unicorn etc.

Image for post

Interaction between your Browser and Python Web Application

But why exactly do we need WSGI?

To understand the real need of WSGI, let’s dive deep into how WSGI came into existence.

Before WSGI, the traditional web server did not understand or had any way to run applications. In the late 1990s, a developer named Grisha Trubetskoy came up with an Apache module called mod_python to execute arbitrary Python code. However, mod_python was not an official specification. It was simply created so they could run Python code on a server. For more than a decade, people kept using mod_python to execute their python code.

#uwsgi #http-request #web-server #wsgi #python-programming

Unveiling the Black-Box Between an HTTP Request and Your Python Code
1.50 GEEK