It’s a good time to be developing applications for the web. There are many web application frameworks out there, which means lots of choices, which means it’s more likely that the thing you need exists. Among the sea of choices, why Tangelo? This post explores some reasons you would want Tangelo to host your application and some reasons you might not.
First, a quick disclaimer. If you’re planning to build a traditional web app with a database, models to represent application data, and views to display it, then existing systems such as Ruby on Rails will match up to your project goals better than Tangelo. In our work, we have been looking beyond, toward scientific simulation and visualization, as well as other unusual applications that must pull together data from many unconventional sources, using experimental technology to process and visualize it.
Django, Flask, Bottle, and CherryPy are all Python-based web frameworks but they tend to relegate Python itself to second-class status, wrapped up in a bit of red tape. Here’s an example, in a file called
import bottle app = bottle.Bottle() @app.route("/hello/<name>") def greet(name="Earthling"): return "Greetings %s, take me to your leader." % (name) bottle.run(app, host="localhost", port=8080)
When run with
python bottle-hello.py, this application will serve a bit of dynamic content at
http://localhost:8080/hello/Roni, but notice how the simple code to create the content is suspended within a spider web of scaffolding around it. In Tangelo, things are much simpler. In your application directory, creating the following file, named
def run(name="Earthling"): return "Greetings %s, take me to your leader." % (name)
and then issuing the command
tangelo --root . will serve this minimal application, which behaves the same way as the Bottle application but with fewer lines of code and no exposure of any framework API. Tangelo’s internal server logic handles the scaffolding you see in lines 1, 3, and 9, while the names of files and directories on disk determine the routing you see in line 5. All that remains is the heart of the web service, expressed in general, Pythonic terms. When we say “first-class citizen,” this is just what we mean: zero-API creation of Python web services in individual files that are composed almost entirely of application logic.
In the excitement over Python, we shouldn’t forget about the humble static content that serves as the foundation of any web application. Serving static content complicates things a bit further for the Bottle application: it needs to declare new routes, listing files or directories to serve at each one. In Tangelo, all you need to do is include the files on disk, in paths that reflect the desired routing – zero-API static content, for free.
The other frameworks mentioned above look largely similar to the Bottle example – we have showed the Bottle example because the other frameworks are all at least as complicated (some significantly more so).
In a later post, we will see some examples of the kinds of things Tangelo can do to solve problems on the web.