Over the past two years, we have been developing Tangelo  in the pursuit of rich web applications for solving problems, both old and new. We recently passed 2,000 commits in the repository , and Tangelo will soon be ready for prime time. This article aims to inform you more about the technology with a high-level introduction to the Tangelo Web Framework. We then answer the question: Why Tangelo?
What is Tangelo?
Here is a silly but illustrative example. Suppose you create this short Python script in the directory being served by Tangelo,
Because of the presence of that
run() function, Tangelo will respond with a string representing the current time.
We can try it out right now. Sep one is to install Tangelo. The easiest way to do so is using the Python package manager Pip:
$ pip install tangelo
Step two is to create the file now.py from the code listing above. Step three is to start Tangelo, letting it know you want to serve files from the current directory:
$ tangelo --root .
(If you get an error in this step, it may be that your computer is already using port 8080, the default, for another application. You can add —port 9090 to the command to choose a different port.)
Step four is to open http://localhost:8080/now in your favorite web browser. You should see the current time displayed. Refresh the browser, and the displayed time should update. Your first Tangelo application is complete!
- Retrieve data from a database using complex query and application-specific post-filtering
- Kick off a long-running compute job on a cluster and periodically check on its progress
- Use specialized visualization tools, such as Bokeh
- Construct a PNG image to display in your webpage using Python imaging libraries
- Use Whizbang, BeesKnees, CatsMeow, or some other new Python module that does something useful, sexy, and fun
In each of these cases, and many others limited only by our collective imagination, Tangelo puts more power in your hands to do what you need to create data sources, analyses, and visualizations.
Interact with other Kitware software
- Girder , for bringing high performance data storage to Tangelo applications
- GeoJS , for creating map-based visualizations and animations
- VTKWeb , to create, control, interact with, and terminate VTK-based visualizations in-browser
Interact with Python packages and other software
- Bokeh , for applying ready-made visualizations to custom data sources
- Vega , to create interactive charts and visualizations
- PyPNG, to construct PNG images of data for use as a thumbnail or a clickable map, etc.
Implement powerful functionality unique to Tangelo
- Convert a basic data service into a streaming service to enable the handling of “big data” sources
Provide help in constructing HTML user interfaces
- A control panel for runtime application options that slides out of the way when not needed
- An SVG legend for use with maps or other SVG diagrams
We mentioned before that Tangelo is aimed toward visualization and analytics applications, and many of our clients, both inside and outside of Kitware, have been using it to good effect that way. But, you can always step outside the box a little bit too. For instance, Tangelo could be used to create system tools, such as a Wifi manager or a print monitor, since Python also affords a way to peek into such system-level services.
The hypothetical tree infographic depicts estimated transmission links using existing
case count data and a generation-based model.
It is a good time to be developing applications for the web. There are many web application frameworks out there, which means lots of choices. It also makes it more likely that what you need exists. So, among the sea of choices, why choose Tangelo?
First, we have a quick disclaimer: If you are planning to build a traditional web application 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’s goals better than Tangelo. In our work, we have been looking beyond, toward scientific simulation and visualization, as well as toward 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. They tend, however, to relegate Python itself to second-class status, as it is wrapped up in a bit of red tape. Here is an example in a file called
app = bottle.Bottle()
return "Greetings %s!" % (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 /hello/Roni. Notice, however, how the simple code to create the content is suspended within a spider web of scaffolding. In Tangelo, things are much simpler. In your application directory, creating the following file, named
hello.py, 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 without exposure of any framework API.
return "Greetings %s!" % (name)
Tangelo’s internal server logic handles the scaffolding you see in the Bottle example, and the names of files and directories on disk implicitly determine the routing. All that remains is the heart of the web service, expressed in general, Pythonic terms. When we say “first-class citizen,” we mean the “zero-API” creation of Python web services in individual files that are composed almost entirely of application logic.
In the excitement over Python, we should not 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 showed the Bottle example because the other frameworks are all at least as complicated (some significantly more so).
Hopefully this gives you a glimpse of the interesting and useful things that will arise from Tangelo’s wider debut. Please take a look at the Tangelo website (http://www.tangelohub.org/tangelo/) for general information or the documentation (http://tangelo.readthedocs.org/en/latest/) to install, set up, and try Tangelo yourself. Drop us a note at firstname.lastname@example.org if you run into trouble, if you have questions, or if you need help.
Tangelo development is sponsored by the Air Force Research Laboratory and DARPA XDATA program.
Dr. Roni Choudhury is a Research and Development Engineer at Kitware. He has directed the design and development of Tangelo from the ground up to bring advanced and experimental information visualization techniques to the web.
Dr. Jeff Baumes is a Technical Leader and Data Scientist at Kitware. His primary responsibility is to create tools that effectively visualize large and complex data, spanning relational, geospatial, temporal, bioinformatics, financial, and textual data.