Introducing WEB2PY: Build a Python web app in less than two minutes

Post to Twitter

I discovered web2py last night. This is unlike any web framework you’ve ever seen and its open source and 100% free. With web2py the batteries are included and there is zero to install additionally or configure. Its all self-contained, in fact you don’t even need a code editor to work with the scripts since one is provided and hosted in the web browser. The language used is Python and you’ll find a Python interpreter is already included as well. Simply download, extract, and then run the executable and your up and running and ready to create your first web app.

[ad name=”Google Adsense”]

The documentation is excellent and includes a rather large introduction to using web2py as well a nice refresher/tutorial on the Python language itself. There are plenty of examples as well.

I did a “Hello World” tutorial in less than two minutes. Once I had web2py downloaded and extracted (I’m using Windows XP on a Virtual Machine) I went ahead and ran the “web2py.exe” file and was greeted with the following window:

The web2py server

I entered “password” as my admin password. Once the server fires up it opens in your default browser to the following introduction page:

Welcome Screen

Clicking on the admin link it takes you to a page that shows what all web apps are installed as well as a way to upload news ones or to create one. In this case I created one called “HelloWorld”.

Creating the Hello World project

From here if you enter the address: you would see this page which is the default page generated with new projects:

The default project

If you look at the code for the controller you see it lays out the code in a nice format right within your browser.

The code highlighting capabilities

Even though web2py already generated the “Hello World” for me – and with a fancier effect I’m still going to modify the code just to show how nice the code editor is they packaged with web2py. So go ahead and edit the “” code.

Code Editor

Change the default code for the “index” method to the following (yes, we are making it pretty ugly and boring by doing this):

Hello World code

Now go ahead and refresh the tab/page where the “HelloWorld” project is running and you should see this.

The end result
(Keep in mind you can edit the index.html view to make it look nicer if you wanted to)

It doesn’t get any easier than that. Make sure to read the excellent documentation over as well as the ease of integrating AJAX and you’ll see this really is a fantastic Python web framework.

[ad name=”Google Adsense – large sqr rounded”]

Post to Twitter

This entry was posted in AJAX, Python. Bookmark the permalink.

12 Responses to Introducing WEB2PY: Build a Python web app in less than two minutes

  1. geo says:

    I think this is an original approach to web development. What do you think about deploying the application?

  2. yarko says:

    Thanks for this nice writeup.

    The standalone executable (available for Windows and Mac), as well as the source version (runable anywhere you have a Python 2.5 or 2.6 interpreter installed) will run with many database engines (no code changes to your web application). Any hosting service that has one of these versions of Python can host a web2py application (I use webfaction, for example). Python comes with sqlite, so that is the default, but you can change a connection string to connect to MS-SQL, MySQL, Oracle, Postgres, and many others. Additionally, web2py works with Google App Engine (again, a change in the connection string; since GAE is not a relational store, see ~ P. 305 of the Web2py documentation for guidelines and caveats)

    – Yarko

  3. Richard says:

    I’ve been using web2py for the last year and agree it’s a fantastic framework – more productive and intuitive than anything else I’ve used (Rails, Django, Turbogears, Symfony).

    Deployment is the downside though because everywhere supports PHP but you have to look harder for Python support.
    Fortunately I found Webfaction, which has worked great.

  4. Paul says:

    I was also impressed by web2py. But the license contains a deal killer for my needs:

    “We allow the redistribution of unmodified binary versions of web2py provided that they contain a link to the official web2py site. This means you can redistribute web2py in binary or other closed source form together with the applications you develop as long as you acknowledge the author.”

    Not that I mind sharing the glory.. but this would cause problems with customer relations. I can’t have extensive comments, disclaimers, copywrites, etc. in the app ‘about’ box.

    I’ll have to stick to BSD, MIT, Apache licensed frameworks.

  5. Babu says:

    Did you try ( I tried web2py, but before I could really dive into that, came across – found it extra ordinarily simple. It is quite performant too.

  6. Joe B. says:

    Web2py is a tremendous time-saver. The things I like about it are:

    1. It’s Python all the way down — even the HTML templating language is Python.

    2. It easily fits (and RUNS) from a USB stick. Now that’s compact and “zero installation”!

    3. It re-hosts its data store automatically on any of the modern databases, including Google App Engine. You can’t beat it for data portability.

    4. It offers very good performance. I’ve seen fairly static pages served at 100 pgs/sec.

    Lots of other reasons to love web2py. It’s a young framework but it is improving fast. The learning curve is short and the ideas behind it are strong. It doesn’t try to replace Django but tries to be a credible alternative to Rails in the Python world. And it more than succeeds at that, it excels.

  7. aspers says:

    Great article

    I find its excellent for developing on Google App Engine. I’ve tried many frameworks and always come back to web2py.

  8. pyjunkie says:

    I agree with license being a deal killer… Its not an app, but a framework…

  9. Michael says:

    Right, the license restrictions are on the web2py code, not on your application code. To me, it says you can distribute your own code under any license you want, with no requirement to link to the web2py site unless you’re also distributing their code.

  10. mdipierro says:

    Correct. The license does not impose ANY restriction on applications developed with web2py, only on derivative work that includes web2py source code, such as a different web framework.

  11. tommed says:

    Or you could try qkweb and create dynamic sites in less than 3 mins! Very lightweight web framework with templates (boilerplate code around 5 lines of python!!).

  12. Pharesm says:

    I don’t get it, all the Web2Py guys are asking is to be given credit if you distribute the stuff they gave you for free, as part of your own commercial closed source package you’re charging your clients money for, and that’s a deal killer?

    I guess you don’t want them to know how easy you managed to make it for yourself, so you can keep overcharging. Business is war after all, and the open source guys’ idealism should be abused where possible.

    I think I get it after all, it makes perfect sense 🙂

Comments are closed.