Chapter 9. An OpenWhisk Web Application in Python

In this chapter, we are going to develop a non-trivial example of an OpenWhisk Python application using CouchDB/Cloudant. The application we are going to develop is a database table editor. The goal is to demonstrate coding in Python, by creating a web user interface that interacts with databases in OpenWhisk. We also cover testing in depth.

For illustration purposes, the application is actually split into two implementations. First we’ll build a basic application, with bare-bones functionality. Then we’ll create a more advanced implementation, with more complex features.


The source code for the examples related to this chapter is available in the GitHub repository.

CRUD Application Architecture

In the basic application, we cover:

  • Implementation and testing of database operations in Python

  • Creation and testing of a simple HTML user interface

  • Implementation and testing by “mocking” of the application control logic

The application, shown in Figure 9-1, has a simple structure. It uses only HTML tables and forms, and a bit of client-side JavaScript. We keep the application features to an absolute minimum here and instead focus on OpenWhisk coding techniques, avoiding too many implementation details. We follow the usual Model-View-Controller pattern for a web application, splitting it into three modules:,, and

Figure 9-1. CRUD application user interface

When invoked, the application shows ...

Get Learning Apache OpenWhisk now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.