orb*_*tal 5 python aws-lambda aws-api-gateway
在这里发帖是因为我无法进行重定向工作。使用链接到 Python Lambda 函数的 AWS API 网关作为代理只返回响应和标头 json。这是代码
import json
def lambda_handler(event, context):
response = {}
response["statusCode"]=301
response["headers"]=[{"key": 'Location',"value":
'https://www.google.com'}]
data = {}
response["body"]=json.dumps(data)
return response
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激?
谢谢
网络上的混合文档令人困惑。使用 Python 时,使用 Location 指定重定向的语法需要如下:
import json
def lambda_handler(event, context):
response = {}
response["statusCode"]=302
response["headers"]={'Location': 'https://www.google.com'}
data = {}
response["body"]=json.dumps(data)
return response
Run Code Online (Sandbox Code Playgroud)