Use this practice project to help sharpen your skills for the phase 4 live code!
- If you don't have
python version 3.9.2
, you may have to install withpyenv install 3.9.2
. You can check withpyenv versions
. You don't have to worry about setting your python version. Just that it's installed. - Run
pipenv shell
to start your virtual environment. - Install the dependencies with
pipenv install
. - cd into
server
. From there you can run the server withpython app.py
You will have two models:
Post:
- has a title
- has content
- has an author
- has many comments
Comment:
- has content
- has a commenter
- belongs to post
Create a GET
route that goes to /api/sorted_posts
. This route should return as json all the posts alphabetized by title
.
Create a GET
route that goes to /api/posts_by_author/<author_name>
. This route should return as json the post by the author's name. For example: /api/posts_by_author/sara
would return all post that belong to sara.
Create a GET
route that goes to /api/search_posts/<title>
. This route should return as json all the posts that include the title. Capitalization shouldn't matter. So if you were to use this route like /api/search_posts/frog
. It would give back all post that include frog
in the title.
Create a GET
route that goes to /api/posts_ordered_by_comments
. This route should return as json the posts ordered by how many comments the post contains in descendeding order. So the post with the most comments would show first all the way to the post with the least showing last.
Create a GET
route that goes to /api/most_popular_commenter
. This route should return as json a dictionary like { commenter: "Bob" }
of the commenter that's made the most comments. Since commenter isn't a model, think of how you can count the comments that has the same commenter name.
For these challenges, you will create all of the routes in the app.py
file. Look for the comment # create routes here:
to know where you will place your code.