Previously, we added a new entry to our database using either a hard-coded piece of code or the DB Viewer. Now, we need to make the add page work for a user who can't do those things. We should be able to add any film and use an API to fetch the poster image, year of release and movie description.

1. Make the add page render when you click on the Add Movie button on the Home page. The Add page should render a WTF form that only contains 1 field - the title of the movie.

e.g.

SOLUTION


2. When the user types a movie title and clicks "Add Movie", your Flask server should receive the movie title. Next, you should use the requests library to make a request and search The Movie Database API for all the movies that match that title.

HINT 1: The "Try it out" tab on the API docs is particularly useful to see the structure of the request and the data you can expect to get back.

HINT 2: We covered how to make API requests a long time ago on Day 33, it might be worth reviewing the knowledge there if you get stuck.

e.g.


SOLUTION


3. Once the user selects a particular film from the select.html page, the id of the movie needs to be used to hit up another path in the Movie Database API, which will fetch all the data they have on that movie. e.g Poster image URLs.

https://developers.themoviedb.org/3/movies/get-movie-details

The data you get back from the API should be used to populate the database with the new entry. The properties you will populate are:

Once the entry is added, redirect to the home page and it should display the new movie as a card. Some data will be missing, that's ok.

e.g.


SOLUTION


4. Instead of redirecting to the home page after finding the correct film, redirect to the edit.html page. Because the parts of the movie entry that are missing are the rating and review. The form on the edit page will contain these two fields. Update the movie entry in the database with this new data.

e.g.


SOLUTION