From the course: Skill Up with Python: Hands-On Web Development Projects

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Create a CREATE endpoint

Create a CREATE endpoint

- All right, so now that we've created two endpoints for reading instances, right, one for listing all of our contacts and one for loading specific instances of our contacts, the next thing that we're going to take a look at is how to create an endpoint that allows us to create new contacts. So generally, while we've been defining all of these other things like all of these other endpoints as GET endpoints, meaning that they respond to GET requests specifically for create endpoints, generally we'll want to respond to POST requests. Now again, these methods don't really mean a whole lot besides they're just kind of indicating the intention of the request. So POST requests, as I said, are generally used to create some sort of data or send some sort of data. And that's why what we'll want to do for our create contact endpoint, which we're going to create here, is say app.post as the decorator, and then of course for the path here, we're going to say /contacts. Now, in case you're…

Contents