试用AWS的Lambda和API Gateway

http://blog.csdn.net/aws0to1/article/details/46990313

 

目标

使用Lambda和API gateway搭建一个HTTP API,返回文本信息

步骤

在Lambda中创建python函数

函数名 helloWorld

函数体:

import json
print('Loading function')

def lambda_handler(event, context):
return "HELLO WORLD"

在API Gateway中创建API访问Lambda函数

点击“Create Resource”按钮

取名字“hello”

选择“Lambda Function”,并选择在前面创建的helloWorld函数

系统会显示一个系统内部响应的示意图。 点击“TEST”按钮

点击“TEST”

在Response Body中显示了预期的结果

使用浏览器访问也能显示相同的结果


 

LEAVE A COMMENT