How can i get the aws lambda response as the HTML page. Please provide the step wise procedure to solve this.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
You don't need Lambda to print out HTML.
Adding the HTML code:
go to your GET method -> Integration Response -> Body Mapping Templates
delete application/json (by default)
add text/html mapping
in the empty field to the right, just paste your HTML (delete anything else)
You will also need to update the content type in the Method Response:
expand 200 response
under Response Body for 200, delete application/json and add text/html with an empty model
Then just deploy your API and you're done.
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.