I gave a talk on the bottle.py web micro-framework at Atlanta’s Python Users Group (PyATL) this evening, sharing the results of an experiment I’ve been running for the past 90 days. To test the framework, I built a small word solver site that helps you play some of the social word games. For example, there is a hangman solver, words with friends helper, and word builder. Experienced developers may recognize some of these projects from CS 101 🙂 The focus of the talk was taking a command line Python program and turning it into a web application. We also discussed the realities of managing the site and generating traffic.
While there are many web frameworks out there, bottle.py is relevant to the analytics space due to it’s simplicity and good integration with JSON. Bottle gives you an efficient way to turn analytics code into web services.
Here’s how it works:
1) Take a fancy analytics module written in Python. Wrap it inside of a bottle.py route decorator (connects HTTP request with function call). You now have a basic web service.
2) Use Jquery / HTML / CSS to write a simple web page. This page collects a query and passes data back to server. The page will then receive an AJAX response which is appended to your page. Now you’ve got a good start on a website.
Bottle.py gives you a much shorter learning curve than the more traditional frameworks. There are several audiences that will find it useful:
1) Experienced developers coming from another language orcoding background. You can dip your toe into Python coding without totally revamping your codebase. This also works for adding a Python service to a PHP / Ruby project.
2) Experienced python devs who want to build a best of breed solution using plugins.
3) Small / portable projects where you don’t need the overhead of a full web framework.
In the interest of being objective, since I am being a bottle.py fanboy here, similar arguments could be made in favor of flask (another leading Python micro framework). Both of these are useful to the audiences above.
For an analyst, this lets you move from passing out PowerPoints to giving your clients a tool they can immediately take action with. This translates into more of your ideas being implemented faster. Pretty empowering when you think about it.