mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
slim down web section
This commit is contained in:
+15
-93
@@ -71,48 +71,16 @@ you may need, such as database access or form generation and validation. For
|
|||||||
many popular modules, `Extensions <http://flask.pocoo.org/extensions/>`_ may
|
many popular modules, `Extensions <http://flask.pocoo.org/extensions/>`_ may
|
||||||
already exist to suit your needs.
|
already exist to suit your needs.
|
||||||
|
|
||||||
**Support** for flask can best be found in its mailing list. Just shoot an email to
|
**Support** for flask can best be found in its mailing list. Just shoot an email to
|
||||||
flask@librelist.com and reply to the confirmation email.
|
flask@librelist.com and reply to the confirmation email.
|
||||||
|
|
||||||
|
|
||||||
Pyramid
|
|
||||||
-------
|
|
||||||
|
|
||||||
.. todo:: Explain Pyramid
|
.. todo:: Explain Pyramid
|
||||||
|
|
||||||
Web.py
|
|
||||||
------
|
|
||||||
|
|
||||||
`web.py <http://webpy.org>`_ is a minimalist web framework that is somewhere between Django and Flask.
|
|
||||||
The premise of web.py is that it is flexible - code your webapp any way you want it, in just python and python alone.
|
|
||||||
web.py comes with some nifty tools built in, like database connection tools and a mini http server.
|
|
||||||
|
|
||||||
**Support** for web.py is quite sparse, but you can look for support in the `mailing list <http://groups.google.com/group/webpy>`_ .
|
|
||||||
|
|
||||||
|
|
||||||
Web Servers
|
Web Servers
|
||||||
:::::::::::
|
:::::::::::
|
||||||
|
|
||||||
Apache
|
|
||||||
------
|
|
||||||
|
|
||||||
mod_python
|
|
||||||
~~~~~~~~~~
|
|
||||||
|
|
||||||
For a long period Apache with mod_python was one of the most reccomended
|
|
||||||
ways to deploy Python applications and thus you may see many tutorials
|
|
||||||
about it on the web or in books, however Apache no longer supports
|
|
||||||
mod_python [1]_ and thus this deployment mechanism is strongly discouraged in
|
|
||||||
favor of WSGI based ones.
|
|
||||||
|
|
||||||
mod_wsgi
|
|
||||||
~~~~~~~~
|
|
||||||
|
|
||||||
Many improvements have been made with mod_wsgi over mod_python for serving
|
|
||||||
Python with Apache [2]_. If you must run the Apache web server, mod_wsgi is
|
|
||||||
your best option for running Python, other than proxying to a dedicated WSGI
|
|
||||||
server.
|
|
||||||
|
|
||||||
.. _nginx-ref:
|
.. _nginx-ref:
|
||||||
|
|
||||||
Nginx
|
Nginx
|
||||||
@@ -125,82 +93,41 @@ application servers (like WSGI servers). It also includes handy features
|
|||||||
like load-balancing, basic authentication, streaming, and others. Designed
|
like load-balancing, basic authentication, streaming, and others. Designed
|
||||||
to serve high-load websites, Nginx is gradually becoming quite popular.
|
to serve high-load websites, Nginx is gradually becoming quite popular.
|
||||||
|
|
||||||
Mongrel2
|
|
||||||
--------
|
|
||||||
|
|
||||||
`Mongrel2 <http://mongrel2.org>`_ is an application, language, and network
|
|
||||||
architecture agnostic web server. It uses a high performance queue (zeromq) to
|
|
||||||
communicate with your applications, all asynchronously. There is a well defined
|
|
||||||
protocol to be used between mongrel2 and a backend handler (your app).
|
|
||||||
|
|
||||||
Brubeck
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
.. todo:: Explain Mongrel2 + Brubeck
|
|
||||||
|
|
||||||
wsgid
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
`Wsgid <http://wsgid.com>`_ is a generic mongrel2 handler that speaks both
|
|
||||||
mongrel2 protocol and WSGI. This makes it possible to run your python webapp
|
|
||||||
written with any WSGI compliant framework. Wsgid has built-in Django support but
|
|
||||||
has also a generic way to load your WSGI application object directly. It's
|
|
||||||
possible to add support for other frameworks through wsgid's pluggable
|
|
||||||
Apploading interface.
|
|
||||||
|
|
||||||
.. rubric:: Resources
|
|
||||||
|
|
||||||
* `Deploying your django application with mongrel2 and wsgid <http://daltonmatos.wordpress.com/2011/11/06/deploying-your-django-application-with-mongrel2-and-wsgid/>`_
|
|
||||||
|
|
||||||
.. _wsgi-servers-ref:
|
.. _wsgi-servers-ref:
|
||||||
|
|
||||||
WSGI Servers
|
WSGI Servers
|
||||||
::::::::::::
|
::::::::::::
|
||||||
|
|
||||||
Stand-alone WSGI servers typically use less resources than traditional web
|
Stand-alone WSGI servers typically use less resources than traditional web
|
||||||
servers and provide top performance [3]_.
|
servers and provide top performance [3]_.
|
||||||
|
|
||||||
.. _gunicorn-ref:
|
.. _gunicorn-ref:
|
||||||
|
|
||||||
gUnicorn
|
Gunicorn
|
||||||
--------
|
--------
|
||||||
|
|
||||||
`gUnicorn <http://gunicorn.org/>`_ (Green Unicorn) is a WSGI server used
|
`Gunicorn <http://gunicorn.org/>`_ (Green Unicorn) is a WSGI server used
|
||||||
to serve Python applications. It is a Python fork of the Ruby
|
to serve Python applications. It is a Python interpretation of the Ruby
|
||||||
`Unicorn <http://unicorn.bogomips.org/>`_ server. gUnicorn is designed to be
|
`Unicorn <http://unicorn.bogomips.org/>`_ server. Unicorn is designed to be
|
||||||
lightweight, easy to use, and uses many UNIX idioms. gUnicorn is not designed
|
lightweight, easy to use, and uses many UNIX idioms. Gunicorn is not designed
|
||||||
to face the internet, in fact it was designed to run behind Nginx which buffers
|
to face the internet, in fact it was designed to run behind Nginx which buffers
|
||||||
slow requests, and takes care of other important considerations. A sample
|
slow requests, and takes care of other important considerations. A sample
|
||||||
setup for Nginx + gUnicorn can be found in the
|
setup for Nginx + gUnicorn can be found in the
|
||||||
`gUnicorn help <http://gunicorn.org/deploy.html>`_.
|
`Gunicorn help <http://gunicorn.org/deploy.html>`_.
|
||||||
|
|
||||||
.. _uwsgi-ref:
|
.. _uwsgi-ref:
|
||||||
|
|
||||||
uwsgi
|
|
||||||
-----
|
|
||||||
|
|
||||||
`uWSGI <http://projects.unbit.it/uwsgi/>`_ is a fast, self-healing and
|
|
||||||
developer/sysadmin-friendly application container server coded in pure C.
|
|
||||||
|
|
||||||
Born as a WSGI-only server, over time it has evolved in a complete stack for
|
|
||||||
networked/clustered web applications, implementing message/object passing,
|
|
||||||
caching, RPC and process management.
|
|
||||||
|
|
||||||
Server Best Practices
|
Server Best Practices
|
||||||
:::::::::::::::::::::
|
:::::::::::::::::::::
|
||||||
|
|
||||||
While Apache will serve your Python application, and many references suggest it,
|
|
||||||
modern best practices suggest against it. With the improvements in mod_wsgi over
|
|
||||||
mod_python, Apache can handle many more requests than before. However, mod_wsgi
|
|
||||||
tends to use more memory than other WSGI solutions [3]_.
|
|
||||||
|
|
||||||
The majority of self hosted Python applications today are hosted with a WSGI
|
The majority of self hosted Python applications today are hosted with a WSGI
|
||||||
server such as :ref:`uWSGI <uwsgi-ref>` or :ref:`gUnicorn <gunicorn-ref>` behind a
|
server such as :ref:`gUnicorn <gunicorn-ref>`, either directly or behind a
|
||||||
lightweight web server such as :ref:`nginx <nginx-ref>` or
|
lightweight web server such as :ref:`nginx <nginx-ref>`.
|
||||||
`lighttpd <http://www.lighttpd.net/>`_.
|
|
||||||
|
|
||||||
The WSGI servers serve the Python applications while the web server handles tasks
|
The WSGI servers serve the Python applications while the web server handles tasks
|
||||||
better suited for it such as static file serving, request routing, DDoS
|
better suited for it such as static file serving, request routing, DDoS
|
||||||
protection, and basic authentication.
|
protection, and basic authentication.
|
||||||
|
|
||||||
Hosting
|
Hosting
|
||||||
@@ -305,19 +232,14 @@ WebFaction
|
|||||||
|
|
||||||
`Webfaction <http://www.webfaction.com/>`_ started off as a dedicated python hosting company.
|
`Webfaction <http://www.webfaction.com/>`_ started off as a dedicated python hosting company.
|
||||||
In fact it used to be called python-hosting.com. Webfaction supports Python versions 2.4 through to 2.7.2
|
In fact it used to be called python-hosting.com. Webfaction supports Python versions 2.4 through to 2.7.2
|
||||||
as well as Python 3 versions.
|
as well as Python 3 versions.
|
||||||
|
|
||||||
Webfaction has a very extensive `user guide <http://docs.webfaction.com/user-guide/>`_
|
Webfaction has a very extensive `user guide <http://docs.webfaction.com/user-guide/>`_
|
||||||
and specific stack (`Django <http://docs.webfaction.com/software/django/index.html>`_, `Pylons <http://docs.webfaction.com/software/pylons.html>`_,
|
and specific stack (`Django <http://docs.webfaction.com/software/django/index.html>`_, `Pylons <http://docs.webfaction.com/software/pylons.html>`_,
|
||||||
`Pyramid <http://docs.webfaction.com/software/pyramid.html>`_, `TurboGears <http://docs.webfaction.com/software/turbogears.html>`_
|
`Pyramid <http://docs.webfaction.com/software/pyramid.html>`_, `TurboGears <http://docs.webfaction.com/software/turbogears.html>`_
|
||||||
and `vanilla python <http://docs.webfaction.com/software/python.html>`_) guides.
|
and `vanilla python <http://docs.webfaction.com/software/python.html>`_) guides.
|
||||||
It also has a stack-overflow style `community <http://community.webfaction.com/>`_ that is quite useful.
|
It also has a stack-overflow style `community <http://community.webfaction.com/>`_ that is quite useful.
|
||||||
|
|
||||||
Twisted
|
|
||||||
:::::::
|
|
||||||
|
|
||||||
|
|
||||||
Node.js.
|
|
||||||
|
|
||||||
.. rubric:: References
|
.. rubric:: References
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user