See how to write some basic code to set the stage for a demo to-do application.
- [Instructor] In the the great tradition of rest api examples, we're going to be roughly basing our work on building a to-do app. We're not really building a complete implementation but using this example to demonstrate concepts that can be applied to any REST application using chalice. In this video we'll put a few pieces in place to support our work later. To get started let's just include a hardcore list of to-do's in our api. So right under the underline three let's create a list of to-do items, called to-do items and actually we'll make it a map of item id as a string to an item. So let's put a few example items in place, we'll say item buy milk and then we'll add another one and we'll say mow lawn. Now let's create a new route that will return the list of items. So right after our index route on line 19, let's add some space and we'll add a new method called to-do's and we'll return the list of items. We have our Amazon map so we'll just use a python list comprehension to turn the map into a list so we'll say v for, then normally this would be like k, v in to-do items .items. To tell chalice that its a route, we'll add app.route annotation like you saw for index. So let's give ourselves a little space on line 18 we'll go down to 19 again and we'll say app.route and we'll just map this to /to-do. Now let's hop over to the terminal and we'll run chalice local again and then in our other window we can go to localhost, 8000/to-do and you see we get back our listed two items. Now that we have some basic code in place let's move on to more advanced routing.
- Serverless components for REST services
- Creating your first Chalice app
- Routing requests
- Customizing responses
- Implementing basic authentication
- Integrating Cognito
- Setting up custom policies
- Splitting up an app
- Writing and running tests
- Creating a CD pipeline with CodePipeline