From the course: Building RESTful APIs with Flask

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Updating a planet using a PUT method

Updating a planet using a PUT method

From the course: Building RESTful APIs with Flask

Start my 1-month free trial

Updating a planet using a PUT method

- [Instructor] We've got our create and read handled. Next we'll turn our attentions to updating existing planetary records. In a real API, you'd probably also want to be able to update users, too, but it's very easy, so I'm just going to work with planets. Before we dive in, I should warn you that there are a lot of Web developers out there who never use the PUT verb. They basically use GET for retrieving data and POST for everything else. It works, but at that point, you aren't using the verbs the way they were designed. If your front-end team doesn't use PUT, you might consider accepting either PUT or POST to allow for a wider range of programming style. I'll scroll down a little bit and add a new endpoint. I'll call my endpoint update_planet. I'll set my methods equal to PUT. I'll add my method signature. Now I'll set to updating this planet. The first thing I'm going to want is the planet ID. I'm going to go ahead and grab that and stick it in a variable called planet_id. What…

Contents