Hi guys,
I’m completely new to API dev and wanted to start playing around with serverless and aws lambda to get a better feeling for it. For this reason I was following this tutorial. Everything worked like a charm and I was able to invoke the function. My next goal was to create a http endpoint. So I’ve added to the serverless.yaml
functions:
mean:
handler: handler.mean
events:
- http:
path: mean
method: post
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true
After deployment I still was able to invoke the function via terminal:
oka@home:~/sless$ serverless invoke -f mean -d ‘{“values”: [1, 2,3]}’
{
“body”: “2.0”,
“headers”: {},
“statusCode”: 200
}
but doing the same in python:
In [120]: import requests
In [121]: data = {'values': [1,2,3,4,5]}
In [122]: a = requests.post(url, data=data)
In [123]: a.json()
Out[123]: {u'message': u'Internal server error'}
In [124]: a
Out[124]: <Response [502]>
What am I doing wrong?