April 13, 2022 By Henrik Loeser 2 min read

How to use IBM Cloud Code Engine to create a backend API for dynamic content in your static website hosted on IBM Cloud Object Storage.

Static websites are great for performance and security. Their architectural model is sometimes referred to as Jamstack (in reference to JavaScript, API and Markup). The static website with its markup (HTML) is hosted on object storage, such as GitHub, GitLab, specialized providers or just simply (cloud) object storage. The embedded JavaScript code can make calls to backend APIs to retrieve dynamic content. This could be maps, feedback forms, guestbooks, etc. 

New tutorial

In a new tutorial, we show how such a backend API can be implemented and deployed to IBM Cloud Code Engine as a serverless app. The app interacts with a Cloudant NoSQL database to manage a simple guestbook (see screenshot at the bottom). The HTML page with the JavaScript code that calls the backend API is hosted on IBM Cloud Object Storage (COS) and made publicly available. See the following diagram for the overall architecture:

Architecture of static website with serverless backend API.

The backend API to create or retrieve the guestbook is a serverless app. The app is automatically scaled, depending on the workload and within its configured limits. If you expect few requests, it could automatically scale down to zero app instances (and not incur charges). In contrast, if you expect many requests and a high load — maybe not for a guestbook but for a discussion forum — you can configure some minimum instances and a higher upper boundary:

Guestbook with sample entries.

Get started

To deploy your own guestbook based on a static website with a serverless backend API, follow the instruction in the new tutorial: Serverless web application and API with Code Engine. The tutorial uses a pre-built container image for the app for ease of use. Alternatively, you could build your own container image using the source code provided in the GitHub repository serverless-guestbook

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn

 

Was this article helpful?
YesNo

More from Cloud

How a US bank modernized its mainframe applications with IBM Consulting and Microsoft Azure

9 min read - As organizations strive to stay ahead of the curve in today's fast-paced digital landscape, mainframe application modernization has emerged as a critical component of any digital transformation strategy. In this blog, we'll discuss the example of a US bank which embarked on a journey to modernize its mainframe applications. This strategic project has helped it to transform into a more modern, flexible and agile business. In looking at the ways in which it approached the problem, you’ll gain insights into…

The power of the mainframe and cloud-native applications 

4 min read - Mainframe modernization refers to the process of transforming legacy mainframe systems, applications and infrastructure to align with modern technology and business standards. This process unlocks the power of mainframe systems, enabling organizations to use their existing investments in mainframe technology and capitalize on the benefits of modernization. By modernizing mainframe systems, organizations can improve agility, increase efficiency, reduce costs, and enhance customer experience.  Mainframe modernization empowers organizations to harness the latest technologies and tools, such as cloud computing, artificial intelligence,…

Modernize your mainframe applications with Azure

4 min read - Mainframes continue to play a vital role in many businesses' core operations. According to new research from IBM's Institute for Business Value, a significant 7 out of 10 IT executives believe that mainframe-based applications are crucial to their business and technology strategies. However, the rapid pace of digital transformation is forcing companies to modernize across their IT landscape, and as the pace of innovation continuously accelerates, organizations must react and adapt to these changes or risk being left behind. Mainframe…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters