From: Carl Worth Date: Mon, 12 Oct 2020 03:52:01 +0000 (-0700) Subject: Switch to parse the x-www-form-urlencoded data in Python X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=d7d9be193276c41ced952fd9172e7ae8c995aa66;p=turbot Switch to parse the x-www-form-urlencoded data in Python Previously, we were doing this in a mapping template within AWS, but I decided that that mechanism was more trouble that it was worth, (it was quite buried in AWS, hard to share across multiple lambdas, and meanwhile this approach is a single line of code). --- diff --git a/turbot_lambda/turbot_lambda.py b/turbot_lambda/turbot_lambda.py index d441565..f3d28f2 100644 --- a/turbot_lambda/turbot_lambda.py +++ b/turbot_lambda/turbot_lambda.py @@ -1,3 +1,4 @@ +from urllib.parse import parse_qs from turbot.rot import rot def turbot_lambda(event, context): @@ -6,4 +7,10 @@ def turbot_lambda(event, context): Currently only calls into the rot() function but may become more sophisticated later on.""" - return rot(event['text']) + body = parse_qs(event['body']) + result = rot(body['text'][0]) + + return { + 'statusCode': 200, + 'body': result + }