Building REST API
Installing Requirements:
For this lab, We only need Flask library and jsonify which can be simply installed by writing their pip commands.
Now, Let's start making our API
Creating a basic Flask Web app:
First, We will import Flask and initialise the app. Then we write the default if condition.

For this lab, We will be making an API that shows a collection of the top 100 IMDB movies and user can search using rank to find the movie and their respective IMDB id.
So, let's define the default route as follows:

To test this, We can simply open a terminal/command prompt/powerShell in the same directory and write:
python "filename".py runserver
In my case file name is app.py so the command will be:
python app.py runserver
We can also directly run the code in the IDE itself.
After running this command it will show us the server on which our app is running:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
In this case, the server is http://127.0.0.1:5000/
If we paste this link on our browser, We will get the following output:

As we have set debug = True, We will be notified about any mistakes or syntax errors in our code.
5
