获取 aws lambda 响应作为 HTML 页面 [英] Get aws lambda response as an HTML page

查看:50
本文介绍了获取 aws lambda 响应作为 HTML 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 aws lambda 响应作为 HTML 页面获取.请提供解决此问题的分步程序.

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

推荐答案

HTML 标记存储在一个变量中并返回它以避免文本被引号括起来.首先将您的 HTML 标记存储在 lambda 函数中的一个变量中,然后返回它.例如在 Node.js 中:

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 .

此处 variableHTML 包含从 lambda 函数传递的 HTML 标记.之后,您需要为 HTTP 状态创建一个响应模型,该模型可通过方法响应访问.这里将响应模型的 Content-Type 设置为 text/html.然后您将获得不带引号的 HTML 页面,浏览器会将其识别为 HTML.

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.

这篇关于获取 aws lambda 响应作为 HTML 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆