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

Bigger isn’t always better: How hybrid AI pattern enables smaller language models

5 min read - As large language models (LLMs) have entered the common vernacular, people have discovered how to use apps that access them. Modern AI tools can generate, create, summarize, translate, classify and even converse. Tools in the generative AI domain allow us to generate responses to prompts after learning from existing artifacts. One area that has not seen much innovation is at the far edge and on constrained devices. We see some versions of AI apps running locally on mobile devices with…

IBM Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

The advantages and disadvantages of private cloud 

6 min read - The popularity of private cloud is growing, primarily driven by the need for greater data security. Across industries like education, retail and government, organizations are choosing private cloud settings to conduct business use cases involving workloads with sensitive information and to comply with data privacy and compliance needs. In a report from Technavio (link resides outside ibm.com), the private cloud services market size is estimated to grow at a CAGR of 26.71% between 2023 and 2028, and it is forecast to increase by…

IBM Newsletters

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