Skip to content

Instantly share code, notes, and snippets.

@SamWSoftware
Created May 20, 2021 10:35
Show Gist options
  • Save SamWSoftware/604b00ba9eb90c2f595360f630b43210 to your computer and use it in GitHub Desktop.
Save SamWSoftware/604b00ba9eb90c2f595360f630b43210 to your computer and use it in GitHub Desktop.
Python version of the Lambda Code
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