#100DaysOfWeb in Python Transcripts
Chapter: Days 85-88: Serverless Python with AWS Lambda
Lecture: The glue: setting up AWS Gateway API

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, we've built our Bottle web app we've set up our Lambda and now we're going to implement the missing key which is the AWS gateway API.
0:11 And that's the thing that glues the two together. So our Bottle web app makes the post requests and this API will trigger the Lambda
0:18 and you'll see that everything comes together in this video. So, going back to the AWS management console I'm going into API gateway.
0:32 And we're going to create a new API REST new API give it a name. Then I'm going to create a new method which will be post.
0:51 Integration type will be Lambda. And here I can define the Lambda function we wrote in the previous lesson. I click save.
1:12 So now we've got an API defined that can receive payload and it will invoke the Lambda. Now I'm going to enable CORS
1:22 which basically means that the API allows for other domains to post to it. And then I'm going to deploy the API.
1:40 New stage, version one. Deploy. And now I get this invoke URL and that's the AWS gateway environment variable we set up at the start.
1:54 So I'm going to copy this I'm going to go back to my app to make sure that all the virtual environments are deactivated
2:04 because now I'm going to set it up in my environment. I'm going to enable it and start our app again. And let's see if this works.
2:25 Of course this is not yet the PEP checker we're still having the calculator Lambda but let's see if this works end to end.
2:35 Okay, fair enough, we're excepting a list which will be the return type for the PEP checker so let me temporarily just make that a string.
2:59 Try this again. Wow, nice, of course this validation does not make sense because again, we're working with a temporary
3:08 more simple Lambda to make the point, but this works. Awesome. Our Lambda calculator, up and running.
3:30 And what happens if I put in that data? Will I get my 400 bad request with a message Lambda function raised a value error
3:41 just as we defined in the previous lesson? Lambda function raised a zero division error. Awesome! So, that was pretty quick and easy.
3:54 I just did a define API post method, enable course deploy it and copy the invoke URL into our environment. And in the next lesson, we're going to write
4:04 our second Lambda, to implement our PEP 8 checker.


Talk Python's Mastodon Michael Kennedy's Mastodon