16) Deploy Your App on the Internet Lesson

WSGI - Web Server Gateway Interface

3 min to complete · By Martin Breuss

In the multi-language tech environment that is the internet, your Django app needs a clear language to communicate with the servers it will run on. Years back, the Python community developed a standard language for that called WSGI, which stands for "Web Server Gateway Interface".

What Does the Web Server Gateway Interface Do

The WSGI standard defines clear rules on how a Python web app can interact with a web server, such as Nginx, Apache, or Gunicorn.

Colorful illustration of a light bulb

Info: You can think of WSGI as a standardized language that Python apps use to communicate with web servers.

Most Python web frameworks implement the WSGI standard, and it has good support for all major web server software. The key concept of deploying with WSGI is an application callable, which the web server uses to communicate with your Python code. It’s commonly provided as an object named application in a Python module accessible to the web server.

Django WSGI

Django's startproject command creates a file <project_name>/wsgi.py that contains such an application callable. It’s used both by Django’s development server and by the dedicated web servers in production WSGI deployments.

That's really all you need to know. If you want to read more, check out Django's docs on the topic, but keep in mind that for now, a very high-level understanding of WSGI is sufficient.

Summary: What is WSGI in Python

  • WSGI (Web Server Gateway Interface) is the standard language for Python apps to communicate with the servers they run on
  • WSGI defines clear rules for how a Python web app can interact with the server using an application callable
  • Django automatically creates the application callable when running the startproject command