Python Web Programming
A good article, but I don't want the Flask web framework (http://flask.pocoo.org/) to go unnoticed. I struggled along with Django for a number of months, and since I was just beginning web development I felt like I was fighting the large framework, even to build the simplest app. Upon discovering Flask I found it refreshingly simple, and when I moved on to more complicated applications I found it scaled beyond 'toy' apps. It really is worth a look for any Python developer.
It's worth pointing to Graham Dumpleton's blog [1] -- he seems to be the Python world's web hosting ninja. See the great slide deck [2] from his recent talk on hosting python web apps [3] -- the deck nicely captures the recent state of the world.
Apache2 + mod_wsgi in Daemon mode is probably the most common approach (especially for VPSs), although I know several people who prefer nginx + gunicorn + supervisor. Both are sane and stable options at this point. (The python web frameworks themselves all speak WSGI and there are about seventeen million of 'em to choose from.)
[2] http://modwsgi.googlecode.com/files/mod_wsgi-pycon-sydney-20...
Seems to me that a better title for this article would be "A history of different ways to use Python in the web" rather than "HOWTO Use Python in the web", since most of the article is spent describing old things that should not be used for new projects.
Interesting that there's no mention of Tornado [1]. (Disclosure: as a co-author of O'Reilly's Introduction to Tornado, I'm biased in its favor.) I haven't played around with Brubeck [2] yet, but I also hear many great things about it.
Needless to say, there are some great Python web servers and frameworks out there that aren't listed on that page.
[1] http://www.tornadoweb.org/
Edit: Added links
Bottle.py is the simplest way to start playing with web programming in python. Mix it with Jinja and there you have it, good enough for any personal project. Then you make your way up with Flask and Django.
* I wish there was a one-file jinja copycat to make it easier to just drop bottle and jinja and start hacking.
This reminds me, whatever happened to Turbogears? Are many people using it? I never really hear people mention using it compared to Django.
I thought long and hard about the "Should I learn Django or Turbogears" question 3 or four years ago, and went with Django. Back then, Django was not yet the "default" answer.
It's a real shame that support for Python Server Pages is as rare as it is in the wild, and that we don't see that kind of capability common in other server side languages. I really think that the ability to mix HTML and server code together painlessly is one of the main advantages that PHP still has today. It's the reason I still use it for new projects even though I dislike almost everything about the language itself.
If I could just say <?coffeescript like that, my programmer-happiness rating would quadruple instantly.
What would be extremely useful is an equivalent of Michael Hartl's "Ruby on Rails Tutorial" (http://ruby.railstutorial.org/ruby-on-rails-tutorial-book) for one of the more popular Python web frameworks...
If someone knows of something similar, please let me know.
I know nothing about python web programming, but I'm hoping to get deep into it very soon. I wanted to point out the framework that I'm planning to use, because I hadn't seen it mentioned in this thread yet.
Why is there a link to python's documentation on HN frontpage? I mean, it's not like it's a new release or, wait for it, was anything new.
Here are some others:
- Python/C API Reference Manual http://docs.python.org/py3k/c-api/ - Higher-order functions and operations on callable objects http://docs.python.org/library/functools.html - Google http://www.google.comThis link might help you all out: http://docs.python.org/release/3.1.5/index.html or are we going to eventually have every single Python doc page posted to HN?
It there's no Python news, that doesn't mean you should post random tutorials instead. This is getting tiresome. Flagged.
Great timing on this. I'm training a very smart & academically accomplished new dev who's spent the last several years pursuing his PhD in CS, but has no idea about web development (I don't consider that a vice).
Fortunately he's one of the awesome, awesome people I can just point at an article and he'll be off and running.
> Most HTTP servers are written in C or C++, so they cannot execute Python code directly – a bridge is needed between the server and the program.
Are there any HTTP servers written in Python (rather than modules)? I'm struggling to think of any.
Great resource.
As a side note, I find it interesting that the Django Book does not contain a chapter on test writing.
Why is something like this being posted? It's been in the docs for ages. Seems like link bait to all the folks drooling over Python lately(of which I am).
undefined
undefined
I like Python for CGI and still use it. Sometimes its all you need instead of frameworks, but Bottle and Flask are great as well.