Tutorial: Getting started with Bottle – a Python web framework

According to the Bottle website: “Bottle is a fast, simple and lightweight WSGI micro web-framework for Python“. According to their Twitter page Bottle originates from Goettingen, Germany (incidently, a lot of German folks follow this blog). At first look you might compare Bottle to Sinatra or Express. I’ll be using PyCharm and Python 2.7.1 on OS X to build these examples but it should work equally well on Windows and Linux with minimal modifications if any.

Create a folder to hold the sample files. Inside the folder create a file called app.py. Grab the development (unstable) copy of bottle.py from here and put it into the same folder as the app.py file (One nice thing about Bottle is that it has no other dependencies other than the Python library). You can also grab the stable version if you want to install Bottle you can by following the docs here.

I’ll borrow the first example from the Bottle website. With the two files ready, go into the app.py file and add the following: