Get aws lambda response as an HTML page

前端 未结 2 1061
我寻月下人不归
我寻月下人不归 2020-12-08 21:26

How can i get the aws lambda response as the HTML page. Please provide the step wise procedure to solve this.

2条回答
  •  青春惊慌失措
    2020-12-08 21:53

    Store the HTML markup in a variable and return it to avoid the text being wrapped in quotes. First store your HTML markup in a variable in the lambda function then return it. For example in Node.js:

    context.succeed({ variableHTML: myContentHtml })

    Here is an example of the mapping template:

    #set($inputRoot = $input.path('$')) $inputRoot.variableHTML .

    Here variableHTML contains the HTML markup passed from the lambda function. After that you needed to create an Response model for HTTP Status, which is accessible through Method Response. Here set the Response model Content-Type as text/html. Then you'll get the HTML page without quotes and the browser recognizes it as HTML.

提交回复
热议问题