Created
May 20, 2021 10:35
-
-
Save SamWSoftware/604b00ba9eb90c2f595360f630b43210 to your computer and use it in GitHub Desktop.
Python version of the Lambda Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def lambda_handler(event, context): | |
if event['httpMethod'] == "GET": | |
return getItem(event) | |
if event['httpMethod'] == "POST": | |
return createCart(event) | |
def getItem(event): | |
item = { | |
"description": 'A red t-shirt', | |
"colour": 'red', | |
"size": 'Medium', | |
"price": '£8.99' | |
} | |
return { | |
"statusCode": 200, | |
"body": json.dumps(item) | |
}; | |
def createCart( event ): | |
body = json.loads(event['body']) | |
print('this was the cart that was passed up') | |
print(body); | |
return { | |
"statusCode": 200, | |
"body": json.dumps({ | |
"message": 'The cart was created' | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment