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

Helping enterprises across regulated industries leverage hybrid cloud and AI

3 min read - At IBM Cloud, we are committed to helping enterprises across industries leverage hybrid cloud and AI technologies to help them drive innovation. For true transformation to begin, we believe it is key to understand the unique challenges organizations are facing—whether it is keeping data secured, addressing data sovereignty requirements or speeding time to market to satisfy consumers. For those in even the most highly regulated industries, we have seen these challenges continue to grow as they navigate changing regulations. We…

Migration Acceleration Program for IBM Cloud

2 min read - The cloud has emerged as a transformative technology platform, offering flexibility, scalability and cost-effectiveness. Enterprise cloud migration strategies seek to be business-driven with an integrated technology, operational and financial adoption plan. Knowing where you are, where you are going, and how you get there is critical to sustainable success. Building an end-to-end plan with confidence can be a daunting undertaking, and enterprise leaders find it challenging to design and execute a cloud migration plan. To address these challenges, we continue…

How Wasabi and IBM help clients deliver on data-driven innovation

2 min read - Last year, Wasabi Technologies and IBM Cloud® joined forces to drive data innovation across hybrid cloud environments, positioning enterprises to run applications across any environment—on premises, in the cloud or at the edge—and enabling users to cost efficiently access and use key business data and analytics in real time. As we head into the second half of 2024, IBM Cloud and Wasabi continue to build new ways to expand their relationship. This growing relationship has the potential to reshape how…

IBM Newsletters

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