Express RESTful API for movies.
- As a standalone app running on your machine.
- install node.js or run
sudo apt-get install nodejs
. git clone
the project thencd
into the directory.- run
npm install
to install the application dependencies.
After installing, run the server using npm start
.
Access the running app in a browser at the URL written to the console (http://0.0.0.0:5000).
To test the API implementation I will use python along with requests
and json
modules.
- check if you have python installed in your machine
python
. pip install requests
to install requests module.
- run the application.
- open another Terminal session
Ctrl + Shift + T
and runpython
, then enter the following code:
import requests
import json
res = requests.get('http://0.0.0.0:5000/')
res.json()
- run the application.
- open another Terminal session
Ctrl+Shift+T
and runpython
, then enter the following code:
import requests
import json
movie = {"Id": "5", "Title": "Avengers:Endgame", "Director": "['Anthony Russo', 'Joe Russo']", "Year": "2019", "Rating": "8.6"}
res = requests.post('http://localhost:5000/', data=json.dumps(movie), headers={'Content-Type': 'application/json'})
res.json()
- run the application.
- open another Terminal session
Ctrl+Shift+T
and runpython
, then enter the following code:
Note: I gonna to update the film Killer Klowns from Outer Space film with The Lord of the Rings: The Two Towers.
import requests
import json
movie = {"Title": "The Lord of the Rings: The Two Towers", "Director": "Peter Jackson", "Year": "2002", "Rating": "8.7"}
res = requests.put('http://0.0.0.0:5000/3', data=json.dumps(movie), headers={'Content-Type': 'application/json'})
res.json()
- run the application.
- open another Terminal session
Ctrl+Shift+T
and runpython
, then enter the following code:
Note: I gonna to delete the Aliens film.
import requests
import json
res = requests.delete('http://192.168.1.5:5000/1')
res.json()
- Nagivate to (http://localhost:5000/external) and see the customized API representaion.
- Navigate to (http://localhost:5000/imdb) and see the customized API collected from IMDb.