Example 2: Using an APIG Trigger to Obtain a Static Web Page

Scenario

This example guides you through the procedure for creating a Python 2.7 function and associating an APIG trigger with it to obtain a static web page.

For details about how to call APIs, see Calling APIs.

Prerequisites

You have created an API group in APIG, and have recorded the ID and subdomain name of the API group.

General Procedure

Create a FunctionGraph function and associate an APIG trigger with it to obtain a static web page. The procedure is as follows:

  1. Creating a Function: Create a function to return a static web page.
  2. Creating a Trigger: Create an APIG trigger.
  3. Call the API of the APIG trigger to obtain a static page.

Step 1: Create a Function to Return a Static Web Page

URI: POST /v2/{project_id}/fgs/functions

For details, see Creating a Function.

Step 2: Create an APIG Trigger

URI: POST /v2/{project_id}/fgs/triggers/{function_urn}

For details, see Creating a Trigger.

Step 3: Call the API of the APIG Trigger to Obtain a Static Web Page

Enter the value of invoke_url in the address bar of a browser to obtain a static web page.

Figure 1 Calling the API