Skip to content

Commit af1c40f

Browse files
committed
working on why wsgi servers are necessary
1 parent 0e2be1f commit af1c40f

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

feeds/all.atom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<feed xmlns="http://www.w3.org/2005/Atom"><title>Matt Makai</title><link href="http://www.fullstackpython.com/" rel="alternate"></link><link href="http://www.fullstackpython.com/feeds/all.atom.xml" rel="self"></link><id>http://www.fullstackpython.com/</id><updated>2014-03-15T09:51:43Z</updated></feed>
2+
<feed xmlns="http://www.w3.org/2005/Atom"><title>Matt Makai</title><link href="http://www.fullstackpython.com/" rel="alternate"></link><link href="http://www.fullstackpython.com/feeds/all.atom.xml" rel="self"></link><id>http://www.fullstackpython.com/</id><updated>2014-03-15T10:26:52Z</updated></feed>

source/content/pages/07-wsgi-servers/0701-wsgi-servers.markdown

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,39 @@ sort-order: 07
77
# WSGI Servers
88
A [Web Server Gateway Interface](http://wsgi.readthedocs.org/en/latest/)
99
(WSGI) server implements the web server side of the WSGI interface for
10-
running Python web applications. The WSGI standard v1.0 is specified in
10+
running Python web applications.
11+
12+
13+
## Why are WSGI servers necessary?
14+
A traditional web server does not understand or have any way to execute Python
15+
code. In the late 1990s, a developer named Grisha Trubetskoy
16+
[came up with an Apache module called mod\_python](http://grisha.org/blog/2013/10/25/mod-python-the-long-story/)
17+
to execute Python code. For several years in the late 1990s and early 2000s,
18+
Apache configured with mod\_python ran most of the Python web applications
19+
on the web.
20+
21+
However, mod\_python wasn't a standard. It was just an implementation that
22+
allowed arbitrary Python code to run on a server. As mod\_python's
23+
development stalled and security vulnerabilities were discovered there
24+
was recognition by the community that a consistent way to execute Python
25+
code for web applications was needed.
26+
27+
Therefore the Python community came up with WSGI as a standard interface that
28+
modules and containers could implement to run Python applications. WSGI is
29+
now the accepted approach for running Python web application code.
30+
31+
32+
## PEP specification
33+
The WSGI standard v1.0 is specified in
1134
[PEP 0333](http://www.python.org/dev/peps/pep-0333/). As of September 2010,
1235
WSGI v1.0 is superseded by
1336
[PEP 3333](http://www.python.org/dev/peps/pep-3333/), which defines the
1437
v1.0.1 WSGI standard.
1538

1639
<img src="theme/img/web-browser-server-wsgi.png" alt="WSGI Server <-> Web server <-> Browser" width="100%" class="technical-diagram" />
1740

41+
42+
## Example configuration
1843
A web server's configuration specifies what requests should be passed to
1944
the WSGI server to process. Once a request is processed and generated by the
2045
WSGI server, the response is passed back through the web server and onto
@@ -127,3 +152,9 @@ Why use WSGI and not just point a web server directly at an application?
127152
[The Beautiful Simplicity of an nginx and uWSGI Deployments](http://bartek.im/blog/2012/07/08/simplicity-nginx-uwsgi-deployment.html)
128153
is great reading for understanding Nginx and uWSGI configurations.
129154

155+
* The Python community made a long effort to
156+
[transition from mod\_python](http://blog.dscpl.com.au/2010/05/modpython-project-soon-to-be-officially.html)
157+
to the WSGI standard. That transition period is now complete and an
158+
implementation of WSGI should always be used instead mod\_python.
159+
160+

wsgi-servers.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,30 @@
7676
<h1>WSGI Servers</h1>
7777
<p>A <a href="http://wsgi.readthedocs.org/en/latest/">Web Server Gateway Interface</a>
7878
(WSGI) server implements the web server side of the WSGI interface for
79-
running Python web applications. The WSGI standard v1.0 is specified in
79+
running Python web applications. </p>
80+
<h2>Why are WSGI servers necessary?</h2>
81+
<p>A traditional web server does not understand or have any way to execute Python
82+
code. In the late 1990s, a developer named Grisha Trubetskoy
83+
<a href="http://grisha.org/blog/2013/10/25/mod-python-the-long-story/">came up with an Apache module called mod_python</a>
84+
to execute Python code. For several years in the late 1990s and early 2000s,
85+
Apache configured with mod_python ran most of the Python web applications
86+
on the web.</p>
87+
<p>However, mod_python wasn't a standard. It was just an implementation that
88+
allowed arbitrary Python code to run on a server. As mod_python's
89+
development stalled and security vulnerabilities were discovered there
90+
was recognition by the community that a consistent way to execute Python
91+
code for web applications was needed.</p>
92+
<p>Therefore the Python community came up with WSGI as a standard interface that<br />
93+
modules and containers could implement to run Python applications. WSGI is
94+
now the accepted approach for running Python web application code. </p>
95+
<h2>PEP specification</h2>
96+
<p>The WSGI standard v1.0 is specified in
8097
<a href="http://www.python.org/dev/peps/pep-0333/">PEP 0333</a>. As of September 2010,
8198
WSGI v1.0 is superseded by
8299
<a href="http://www.python.org/dev/peps/pep-3333/">PEP 3333</a>, which defines the
83100
v1.0.1 WSGI standard.</p>
84101
<p><img src="theme/img/web-browser-server-wsgi.png" alt="WSGI Server <-> Web server &lt;-&gt; Browser" width="100%" class="technical-diagram" /&gt;</p>
102+
<h2>Example configuration</h2>
85103
<p>A web server's configuration specifies what requests should be passed to
86104
the WSGI server to process. Once a request is processed and generated by the
87105
WSGI server, the response is passed back through the web server and onto
@@ -201,6 +219,12 @@ <h2>WSGI Resources</h2>
201219
<a href="http://bartek.im/blog/2012/07/08/simplicity-nginx-uwsgi-deployment.html">The Beautiful Simplicity of an nginx and uWSGI Deployments</a>
202220
is great reading for understanding Nginx and uWSGI configurations.</p>
203221
</li>
222+
<li>
223+
<p>The Python community made a long effort to
224+
<a href="http://blog.dscpl.com.au/2010/05/modpython-project-soon-to-be-officially.html">transition from mod_python</a>
225+
to the WSGI standard. That transition period is now complete and an
226+
implementation of WSGI should always be used instead mod_python.</p>
227+
</li>
204228
</ul>
205229
<br/>
206230
Next read the

0 commit comments

Comments
 (0)