我正在使用节点无服务器和 python 在 AWS 上部署服务。使用的服务:S3、API-Gateway、Cloudformation、Lambda。
问题是......我得到了空的响应体:
{
"statusCode": 200,
"isBase64Encoded": false,
"headers": {
"Content-Type": "application/json"
},
"body": "{}"
}
Run Code Online (Sandbox Code Playgroud)
字段“body”是空的。当我用 POSTMAN 测试时也是如此。但是当我在 lambda 上测试时它工作正常:
{
"statusCode": 200,
"isBase64Encoded": false,
"headers": {
"Content-Type": "application/json"
},
"body": "{\"55b7badc-75af-41c0-9877-af308264cb33\":\"0.4666666666666667\",\"4694e172-322e-4a51-930e-d3b9bfd3c2e6\":\"0.36363636363636365\",\"c5447cc5-936d-4aa6-97c4-3f51a7e7c283\":\"0.3\",\"6abf0893-5d32-4a43-942f-aaef4395d91d\":\"0.2727272727272727\",\"c0bf1214-fb41-48eb-b07d-f81b71ba0061\":\"0.25\"}"
}
Run Code Online (Sandbox Code Playgroud)
这是 yml 文件:
service: collaborative
provider:
name: aws
runtime: python3.6
region: eu-west-1
defaults:
stage: dev1
region: eu-west-1
package:
include:
- collaborative
exclude:
- .git
- .idea
- .col_ser.txt
custom:
integration: lambda
functions:
collaborative:
name: lambda-collaborative
handler: handler.lambda_handler
events:
- http:
path: recommend_user
method: …Run Code Online (Sandbox Code Playgroud)