mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
update to web
This commit is contained in:
+31
-80
@@ -61,6 +61,7 @@ project as-is, or customized to fit your needs.
|
|||||||
There are annual Django conferences `in the United States
|
There are annual Django conferences `in the United States
|
||||||
<http://djangocon.us>`_ and `in Europe <http://djangocon.eu>`_.
|
<http://djangocon.us>`_ and `in Europe <http://djangocon.eu>`_.
|
||||||
|
|
||||||
|
The majority of new Python web applications today are built with Django.
|
||||||
|
|
||||||
Flask
|
Flask
|
||||||
-----
|
-----
|
||||||
@@ -84,61 +85,29 @@ For those that do, there are many
|
|||||||
`Extensions <http://flask.pocoo.org/extensions/>`_ available that may
|
`Extensions <http://flask.pocoo.org/extensions/>`_ available that may
|
||||||
suit your needs. Or, you can easily use any library you want yourself!
|
suit your needs. Or, you can easily use any library you want yourself!
|
||||||
|
|
||||||
|
Flask is default choice for any Python web application that isn't a good
|
||||||
Web.py
|
fit for Django.
|
||||||
------
|
|
||||||
`Web.py <http://webpy.org/>`_ is a web framework for Python that is as
|
|
||||||
simple as it is powerful. You won't find wizards or boilerplate websites
|
|
||||||
in Web.py and will have to build from scratch. Web.py provides no administration
|
|
||||||
utility. Web.py is the brainchild of Aaron Swartz, who developed it while working
|
|
||||||
on Reddit.com.
|
|
||||||
|
|
||||||
|
|
||||||
Web2py
|
|
||||||
------
|
|
||||||
A full stack web framework and platform focused in the ease of use. It focuses on
|
|
||||||
rapid development, favors convention over configuration approach and follows a
|
|
||||||
model–view–controller (MVC) architectural pattern.
|
|
||||||
|
|
||||||
|
|
||||||
Werkzeug
|
|
||||||
--------
|
|
||||||
|
|
||||||
`Werkzeug <http://werkzeug.pocoo.org/>`_ is not actually a real framework, but
|
|
||||||
rather a very powerful set of tools for building web applications. It provides
|
|
||||||
URL routing utilities, request and response objects and a basic development
|
|
||||||
server. It is mostly used where users need more flexibility for their
|
|
||||||
application than is commonly found in other web frameworks.
|
|
||||||
|
|
||||||
Support can be found on its `mailing list <http://werkzeug.pocoo.org/community/#mailinglist>`_.
|
|
||||||
|
|
||||||
|
|
||||||
Tornado
|
Tornado
|
||||||
--------
|
--------
|
||||||
`Tornado <http://www.tornadoweb.org/>`_ is a scalable, non-blocking web server
|
|
||||||
and web application framework with a relative simple usage. Tornado is known
|
|
||||||
for its high performance. It was initially developed for
|
|
||||||
`friendfeed <http://friendfeed.com/>`_ , a real time chat and blog system.
|
|
||||||
|
|
||||||
In the Jinja2 template engine example it is used to serve the rendered pages.
|
|
||||||
|
|
||||||
|
`Tornado <http://www.tornadoweb.org/>`_ is an asyncronous web framework
|
||||||
|
for Python that has its own event loop. This allows it to natively support
|
||||||
|
WebSockets, for example. Well-written Tornado applications are known to
|
||||||
|
have excellent performance charecteristics.
|
||||||
|
|
||||||
Pyramid
|
Pyramid
|
||||||
--------
|
--------
|
||||||
|
|
||||||
`Pyramid <http://www.pylonsproject.org/>`_ lies somewhere between a big
|
`Pyramid <http://www.pylonsproject.org/>`_ is a lot like Django, except
|
||||||
framework like Django and the microframeworks: It comes with a lot of libraries
|
with a heavier focus on modularity. It comes with a smaller number of
|
||||||
and functionality and can thus not be considered lightweight. On the other
|
libraries ("batteries") built-in, and encourages users to extend its
|
||||||
hand, it does not provide all the functionality Django does. Instead Pyramid
|
base functionality.
|
||||||
brings basic support for most regular tasks and provides a great deal of
|
|
||||||
extensibility. Additionally, Pyramid has a huge focus on complete
|
|
||||||
`documentation <http://docs.pylonsproject.org/en/latest/docs/pyramid.html>`__.
|
|
||||||
As a little extra it comes with the Werkzeug Debugger which allows you to debug
|
|
||||||
a running web application in the browser.
|
|
||||||
|
|
||||||
**Support** can also be found in the
|
|
||||||
`documentation <http://docs.pylonsproject.org/en/latest/index.html#support-desc>`__.
|
|
||||||
|
|
||||||
|
Pyramid does not have a large user base, ulike Django and Flask (or even
|
||||||
|
Tornado). It's a capable framework, but not a very popular choice for
|
||||||
|
new Python web applications today.
|
||||||
|
|
||||||
Web Servers
|
Web Servers
|
||||||
:::::::::::
|
:::::::::::
|
||||||
@@ -169,14 +138,16 @@ servers and provide top performance [3]_.
|
|||||||
Gunicorn
|
Gunicorn
|
||||||
--------
|
--------
|
||||||
|
|
||||||
`Gunicorn <http://gunicorn.org/>`_ (Green Unicorn) is a WSGI server used
|
`Gunicorn <http://gunicorn.org/>`_ (Green Unicorn) is a pure-python WSGI
|
||||||
to serve Python applications. It is a Python interpretation of the Ruby
|
server used to serve Python applications. Unlike other Python web servers,
|
||||||
`Unicorn <http://unicorn.bogomips.org/>`_ server. Unicorn is designed to be
|
it has a thoughtful user-interface, and is extremely easy to use and
|
||||||
lightweight, easy to use, and uses many UNIX idioms. Gunicorn is not designed
|
configure.
|
||||||
to face the internet -- it was designed to run behind Nginx which buffers
|
|
||||||
slow requests and takes care of other important considerations. A sample
|
Gunicorn has sane and reasonable defaults for configurations. However, some
|
||||||
setup for Nginx + Gunicorn can be found in the
|
other servers, like uWSGI, are tremendously more customizable, and therefore,
|
||||||
`Gunicorn help <http://gunicorn.org/index.html#deployment>`_.
|
are much more difficult to effectively user.
|
||||||
|
|
||||||
|
Gunicorn is the default choice for new Python web applications today.
|
||||||
|
|
||||||
.. _uwsgi-ref:
|
.. _uwsgi-ref:
|
||||||
|
|
||||||
@@ -196,6 +167,7 @@ Python, passing environment variables and further tuning. For full details,
|
|||||||
see `uWSGI magic
|
see `uWSGI magic
|
||||||
variables <https://uwsgi-docs.readthedocs.org/en/latest/Vars.html>`_.
|
variables <https://uwsgi-docs.readthedocs.org/en/latest/Vars.html>`_.
|
||||||
|
|
||||||
|
I do not recommend usign uWSGI unless you think you need to.
|
||||||
|
|
||||||
.. _server-best-practices-ref:
|
.. _server-best-practices-ref:
|
||||||
|
|
||||||
@@ -235,40 +207,19 @@ logging, scheduled and background tasks, billing and payment, etc.
|
|||||||
Heroku
|
Heroku
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
`Heroku <http://www.heroku.com/>`_'s
|
`Heroku <http://www.heroku.com/python>`_ offers first-class support for
|
||||||
`Cedar stack <http://devcenter.heroku.com/articles/cedar>`_ offers first class
|
Python 2.7–3.5 applications.
|
||||||
support for Python 2.7 applications.
|
|
||||||
|
|
||||||
Heroku allows you to run as many Python web applications as you like, 24/7 and
|
Heroku allows you to run Python web applications free of charge. It is best
|
||||||
free of charge. Heroku is best described as a horizontal scaling platform. They
|
described as a horizontal scaling platform. They start to charge you once you
|
||||||
start to charge you once you "scale" your application to run on more than one
|
"scale" your application to run in production. Hobby pricing is available.
|
||||||
Dyno (abstracted servers) at a time.
|
|
||||||
|
|
||||||
Heroku maintains `articles <https://devcenter.heroku.com/categories/python>`_
|
Heroku maintains `articles <https://devcenter.heroku.com/categories/python>`_
|
||||||
on using Python with Heroku as well as `step-by-step instructions
|
on using Python with Heroku as well as `step-by-step instructions
|
||||||
<https://devcenter.heroku.com/articles/getting-started-with-python>`_ on
|
<https://devcenter.heroku.com/articles/getting-started-with-python>`_ on
|
||||||
how to set up your first application.
|
how to set up your first application.
|
||||||
|
|
||||||
|
Heroku is the recommended PaaS for deploying Python web applications today.
|
||||||
DotCloud
|
|
||||||
~~~~~~~~
|
|
||||||
|
|
||||||
`DotCloud <http://www.dotcloud.com/>`_ supports WSGI applications and
|
|
||||||
background/worker tasks natively on their platform. Web applications run
|
|
||||||
Python version 2.6, use :ref:`nginx <nginx-ref>` and :ref:`uWSGI
|
|
||||||
<uwsgi-ref>`, and allow custom configuration of both for advanced users.
|
|
||||||
|
|
||||||
DotCloud uses a custom command-line API client which can work with
|
|
||||||
applications managed in git repositories or any other version control
|
|
||||||
system.
|
|
||||||
|
|
||||||
DotCloud has a free plan with limited database size, and without extra
|
|
||||||
services (caching…).
|
|
||||||
|
|
||||||
See the `DotCloud documentation on Python
|
|
||||||
<http://docs.dotcloud.com/services/python/>`_ for more information and help
|
|
||||||
getting started.
|
|
||||||
|
|
||||||
|
|
||||||
Gondor
|
Gondor
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|||||||
Reference in New Issue
Block a user