我是
aws lambda
的新手,我创建了一个用 python 编写的函数,我有 aws api gateway
作为我的函数的触发器。
运行时间是
python 3.11
现在!这是我什至无法解释的问题:
import json
def lambda_handler(event, context):
# TODO implement
query = event.get('queryStringParameters', {})
#that line causes the problem
challeng = query.get('challenge', None)
return {
'statusCode':200,
'body': 'xyz'
}
并且由于 lambda 没有日志来跟踪代码中的问题(如果有)
您应该能够使用以下语法访问这些参数
import json
def lambda_handler(event, context):
# TODO implement
query = event["queryStringParameters"]
#that line causes the problem
challenge = query["challenge"]
return {
"statusCode": 200,
"headers": { "content-type": "application/json"},
"body": json.dumps(challenge)
}