Abstract: Serverless hosting static website, your first serverless practice, come and experience it!
This article is shared from the HUAWEI CLOUD community " Complete Static Website Hosting in Three Minutes—Practice of Going to the Cloud in Seconds with One Line of Code " by AppCloud Assistant.
foreword
Serverless hosting static website, your first serverless practice, come and experience it!
Friends who are interested in more practice on the cloud, welcome to scan the QR code at the end of the article to join our practice group and complete the weekly practice~
Operating procedures
- create function
- modify the code
- online debugging
- create trigger
- visit page
- delete function
Operation guide
create function
After logging in to HUAWEI CLOUD, click the path "Products" - "Computing" - "Function Workflow FunctionGraph" to enter the homepage of the HUAWEI CLOUD Function Workflow FunctionGraph platform.
Huawei Cloud official website: https://www.huaweicloud.com/
Click the "Use Now" button to enter the FunctionGraph homepage.
Switch the region to "Guangzhou" and click the "Create Function" button
On the create function page, configure the project according to the following parameters
- Select "Create Blank Function"
- Function type: event function
- Region: South China - Guangzhou
- Function name: homepage
- Runtime: Node.js 14.18
- Click "Create Function" to complete the creation
Modify function code
Visit the open source code repository: https://gitee.com/HuaweiCloudDeveloper/code-on-huaweicloud
Select the "Function Workflow Static Website Hosting-homepage" folder
Open the "index.js" file and copy the code
Go back to FunctionGraph, click "Code" on the function page, open the "index.js" file, paste the code, and click the "Deploy" button.
Visit the code warehouse, open the "homepage.html" file, and copy the code
Click "File" - "New File", rename it to "homepage.html", copy the code in "homepage.html" in the code warehouse, and click "Deploy"
online debugging
Click "Test", and the result feedback of "Execution Successful" appears on the right.
create trigger
On the function overview page, click Create Trigger.
On the create trigger page, complete the following configurations:
- Trigger Type: API Gateway Service (APIG)
- API name: API_homepage
- Group: need to create by yourself, optional after refreshing (see below for details)
- Security Authentication: None
- Request protocol: HTTPS
- Other items default
Click "Create Group" to enter the API Gateway, customize the group name, and click "OK" to complete the creation.
On the create trigger page, click the "OK" button to complete the creation, as follows.
visit page
Copy the "Call URL" in the trigger, and visit it in the browser to visit the personal homepage.
delete function
After the experiment is over, triggers and functions can be deleted to prevent resource consumption caused by a large number of users continuing to visit.
Click to follow and learn about Huawei Cloud's fresh technologies for the first time~