@@ -92,7 +92,56 @@ <h2>Why are WSGI servers necessary?</h2>
9292< p > Therefore the Python community came up with WSGI as a standard interface that< br />
9393modules and containers could implement to run Python applications. WSGI is
9494now the accepted approach for running Python web application code. </ p >
95- < h2 > PEP specification</ h2 >
95+ < h2 > WSGI's Purpose</ h2 >
96+ < p > Why use WSGI and not just point a web server directly at an application?</ p >
97+ < ul >
98+ < li >
99+ < p > < strong > WSGI gives you flexibility</ strong > . Application developers can swap out
100+ web stack components for others. For example, a developer can switch from
101+ Green Unicorn to uWSGI without modifying the application or framework
102+ that implements WSGI.
103+ From < a href ="http://www.python.org/dev/peps/pep-3333/ "> PEP 3333</ a > :</ p >
104+ < p > The availability and widespread use of such an API in web servers for
105+ Python [...] would separate choice of framework from choice of web
106+ server, freeing users to choose a pairing that suits them, while
107+ freeing framework and server developers to focus on their preferred
108+ area of specialization.</ p >
109+ </ li >
110+ < li >
111+ < p > < strong > WSGI servers promote scaling</ strong > . Serving thousands of requests for dynamic
112+ content at once is the domain of WSGI servers, not frameworks.
113+ WSGI servers handle processing requests from the web server and deciding
114+ how to communicate those requests to an application framework's process.
115+ The segregation of responsibilities is important for efficiently scaling
116+ web traffic.</ p >
117+ </ li >
118+ </ ul >
119+ < p > WSGI is by design a simple standard interface for running Python code. As
120+ a web developer you won't need to know much more than</ p >
121+ < ul >
122+ < li >
123+ < p > what WSGI stands for (Web Server Gateway Inteface)</ p >
124+ </ li >
125+ < li >
126+ < p > that a WSGI container is a separate running process that runs on a
127+ different port than your web server</ p >
128+ </ li >
129+ < li >
130+ < p > your web server is configured to pass requests to the WSGI container which
131+ runs your web application, then pass the response (in the form of HTML)
132+ back to the requester</ p >
133+ </ li >
134+ </ ul >
135+ < p > If you're using a standard web framework such as Django, Flask, or
136+ Bottle, or almost any other current Python framework, you don't need to worry
137+ about how frameworks implement the application side of the WSGI standard.
138+ Likewise, if you're using a standard WSGI container such as Green Unicorn,
139+ uWSGI, mod_wsgi, or gevent, you can get them running without worrying about
140+ how they implement the WSGI standard.</ p >
141+ < p > However, knowing the WSGI standard and how these frameworks and containers
142+ implement WSGI should be on your learning checklist though as you become
143+ a more experienced Python web developer.</ p >
144+ < h2 > Official WSGI specifications</ h2 >
96145< p > The WSGI standard v1.0 is specified in
97146< a href ="http://www.python.org/dev/peps/pep-0333/ "> PEP 0333</ a > . As of September 2010,
98147WSGI v1.0 is superseded by
@@ -142,55 +191,6 @@ <h2>Example configuration</h2>
142191< p > Note that the above code is a simplified version of a production-ready Nginx
143192configuration. For real SSL and non-SSL templates, take a look at the
144193< a href ="https://github.com/makaimc/underwear/tree/master/underwear/roles/web/templates "> Underwear web server templates</ a > on GitHub.</ p >
145- < p > WSGI is by design a simple standard interface for running Python code. As
146- a web developer you won't need to know much more than</ p >
147- < ul >
148- < li >
149- < p > what WSGI stands for (Web Server Gateway Inteface)</ p >
150- </ li >
151- < li >
152- < p > that a WSGI container is a separate running process that runs on a
153- different port than your web server</ p >
154- </ li >
155- < li >
156- < p > your web server is configured to pass requests to the WSGI container which
157- runs your web application, then pass the response (in the form of HTML)
158- back to the requester</ p >
159- </ li >
160- </ ul >
161- < p > If you're using a standard web framework such as Django, Flask, or
162- Bottle, or almost any other current Python framework, you don't need to worry
163- about how frameworks implement the application side of the WSGI standard.
164- Likewise, if you're using a standard WSGI container such as Green Unicorn,
165- uWSGI, mod_wsgi, or gevent, you can get them running without worrying about
166- how they implement the WSGI standard.</ p >
167- < p > However, knowing the WSGI standard and how these frameworks and containers
168- implement WSGI should be on your learning checklist though as you become
169- a more experienced Python web developer.</ p >
170- < h2 > WSGI's Purpose</ h2 >
171- < p > Why use WSGI and not just point a web server directly at an application?</ p >
172- < ul >
173- < li >
174- < p > < strong > WSGI gives you flexibility</ strong > . Application developers can swap out
175- web stack components for others. For example, a developer can switch from
176- Green Unicorn to uWSGI without modifying the application or framework
177- that implements WSGI.
178- From < a href ="http://www.python.org/dev/peps/pep-3333/ "> PEP 3333</ a > :</ p >
179- < p > The availability and widespread use of such an API in web servers for
180- Python [...] would separate choice of framework from choice of web
181- server, freeing users to choose a pairing that suits them, while
182- freeing framework and server developers to focus on their preferred
183- area of specialization.</ p >
184- </ li >
185- < li >
186- < p > < strong > WSGI servers promote scaling</ strong > . Serving thousands of requests for dynamic
187- content at once is the domain of WSGI servers, not frameworks.
188- WSGI servers handle processing requests from the web server and deciding
189- how to communicate those requests to an application framework's process.
190- The segregation of responsibilities is important for efficiently scaling
191- web traffic.</ p >
192- </ li >
193- </ ul >
194194< h2 > WSGI Resources</ h2 >
195195< ul >
196196< li >
0 commit comments