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.
Adding planets with a POST method
From the course: Building RESTful APIs with Flask
Adding planets with a POST method
- [Instructor] In most CRUD applications, there are usually two read operations and we've completed both of them. There's one to get a list and a second to get the detail. Now let's turn our attention to adding new planetary discoveries. The steps are simple because you've seen everything already. You know how to create new records in the database. You even know how to check first to see if there's already a record there that matches any criteria you'd care to check. We did this earlier when we created the registration route. The only wrinkle is that this is going to be a protected route but we'll deal with that later. I recommend you first create your route unprotected since it makes it easier to test then once it works, go ahead and add the JWT protection on top of it. So I'll go ahead and add my route and I'll call it add_planet and since we're creating a record, it's appropriate for this to accept only host requests. Next, I'll add my method signature. And what I'm going to do in…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.