Building a POST/PATCH/DELETE API Lab (CodeGrade)

Learning Goals


Key Vocab


Instructions

This is a test-driven lab. Run pipenv install to create your virtual environment and pipenv shell to enter the virtual environment. Then run pytest -x to run your tests. Use these instructions and pytest 's error messages to complete your work in the server/ folder. Make sure to test your routes in Postman as you progress.

$ pipenv install
$ pipenv shell

In this application, we'll be working on a familiar JSON API to get a list of bakeries and their baked goods. We have two models, bakeries and baked goods, in a one-to-many relationship. The migrations are already set up. Here's a reminder of what the ERD for these tables looks like:

Bakeries ERD

You can pick up where we left off by entering the following commands:

$ cd server
$ flask db upgrade
$ python seed.py
$ python app.py

Edit server/app.py to support the following requests:

Once all of your tests are passing, commit and push your work using git to submit.

Examples

POST /baked_goods

POST request with form data for a baked good's name, price, and bakery_id

PATCH request with form data for a bakery's name

DELETE request for baked good by ID

NOTE: You can use Postman to make get requests for bakeries and baked_goods before and after your post, patch, and delete requests to ensure the correct record is being added, updated, or deleted.


Resources

Powered by Forestry.md