15.3 Defining web services as functions
We’ll look at a RESTful web service, which can slice and dice a source of data and provide downloads as JSON, XML, or CSV files.
The direct use of WSGI for this kind of application isn’t optimal because we need to create a great deal of ”boilerplate” processing for all the details of conventional website processing. A more effective approach is to use a more sophisticated web server like Flask, Django, Bottle, or any of the frameworks listed here: https://wiki.python.org/moin/WebFrameworks. These servers handle the conventional cases more completely, allowing us—as developers—to focus on the unique features of a page or site.
We’ll use a simple dataset with four series of data pairs: the Anscombe Quartet. We looked at ways to read and parse this data in Chapter 3, Functions, Iterators, and Generators. It’s a small set of data, but it can be used to show the principles of a RESTful web...