Wednesday, June 6, 2012

Bottle Python framework is useful for small web apps

By Vasudev Ram

Bottle is a small Python web framework.

It can be useful for creating small / experimental web apps in Python.

It's easy to get started with. Installation is simple.

Creating small apps is also fairly easy.

The Hello World app is just this:

from bottle import route, run

def index(name='World'):
    return 'Hello %s!' % name

run(host='localhost', port=8080)

I have been trying it out over the last few days and found it a good fit for the uses described above.

Like many web frameworks these days, it comes with a built-in development web server, so you don't have to spend time fiddling around trying to make it work with Apache or other servers - at least, not until you are ready to deploy your app in production.

Actually, as per the docs, running Bottle with CherryPy, Fapws3, Flup or Paste is simple. For example, this is how to use Paste (and it's similar for the others):

from bottle import PasteServer

And the docs specify how to make it work on Apache with mod_wsgi.

I like the way the routes (URL-to-function mappings) are specified in Bottle.

- Vasudev Ram - Dancing Bison Enterprises

No comments: