Additional Functionality

If you would like to go above and beyond, you may work on these ideas after you have completed the rest of the project. They will not give you extra credit; please do not submit them to the Google Form, but if you would like a TA to look at them, you can email the relevant files to cs0111tas@lists.brown.edu.

  1. Your search is likely done in linear time (by going through every book). Can you think of a way to speed this up by using hashtables? For example, if I type in “nonfiction” ideally your code does not search through every book to find nonfiction books, but rather can immediately jump to a list of nonfiction books.
    Hint: You may find string.lower() and string.split(' ') useful.
  2. Modify your code to use defaultdict (which you’ll have to import using from collections import defaultdict) where possible. Use Google and Stack Overflow to figure out how defaultdicts work! This shouldn’t be as hard as #1, but you’ll learn more from #1.
  3. Modify your code to use Python sets for the cart and purchases (you will have to change type annotations for get_cart and get_purchases, but that won’t effect the functionality of the site!).
  4. Make your site multi-user friendly. To do this, you will have to modify app.py and the files in static and templates. It will likely be useful to read the Flask documentation for the session variable. Warning: this will take a lot of work, especially if you do user login. We only recommend doing this if you are particularly interested in web development and have a lot of free time!