Hopefully, you've played around with the code in the previous lesson and you're now able to perform CRUD operations as well as create tables and databases with SQLAlchemy.
Because now comes the final challenge.
You're going to build an SQLite database into the Flask Website we built at the beginning of today. So that any books added are stored in the database and you're also going to build in some extra features to take advantage of the full CRUD features of our database.
You should be able to add new books via the /add route, once a book is successfully added to the database, it should redirect to the home page.
The home page should show all the books in the database:
Add an Edit Rating Anchor Tag to each book <li>
. When the button is pressed, it should take the user to an Edit Rating page where you can enter a new rating for that book. Then when you click "Change Rating" it should take you back to the home page and the new rating should be displayed next to the book. e.g.
HINT: You'll need to think about how to pass the book id as a parameter when you make the GET request to show the edit rating page. There are many ways you can do this. Here are some things that might help:
https://flask.palletsprojects.com/en/2.3.x/quickstart/#url-building
Add a Delete Anchor Tag to each book listing <li>
. When clicked it should delete the book from the database and redirect back to the home page. e.g.
You can also download the COMPLETED PROJECT from this lesson's resources.