Casting agncy final project for udacity aims to collect data of actors and movies and to de any modification on them. the project has three users: 1.Casting Assistant 2. Casting Director 3. Casting Director each of them has a specefic role and permissions.
Locally: http://127.0.0.1:5000/ Heroku: https://casting-agency-reema-ah.herokuapp.com/
Follow instructions to install the latest version of python for your platform in the python docs
Create Virtual Env by running:
virtualenv --python=python3.7 venv
install dependencies by running:
pip install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt
file.
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
jose JavaScript Object Signing and Encryption for JWTs. Useful for encoding, decoding, and verifying JWTS.
From within the ./starter
directory first ensure you are working using your created virtual environment.
Each time you open a new terminal session, run:
export FLASK_APP=app.py;
To run the server, execute:
flask run --reload
The --reload
flag will detect file changes and restart the server automatically.
-
Create a new Auth0 Account
-
Select a unique tenant domain
-
Create a new, single page web application
-
Create a new API
-
in API Settings:
- Enable RBAC
- Enable Add Permissions in the Access Token
-
Create new API permissions:
- get:actors
- get:movies
- delete:actors
- delete:movies
- post:actors
- post:movies
- patch:actors
- patch:movies
-
Create new roles for:
- Casting Assistant: Can view actors and movies
- Casting Director:
- All permissions a Casting Assistant has and…
- Add or delete an actor
- Modify actors or movies
- Executive Producer: Can perform all actions
- Genreal
- Fetches a dictionary of actors
- Request Arguments: None
- Returns: An object that contains actors array, and a success boolean value.
- Sample:
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:5000/actors
{
"actors":[
{"age":51,"gender":"Female","id":1,"name":"Jennifer aniston"},
{"age":52,"gender":"Male","id":2,"name":"Will smith"},
{"age":46,"gender":"Male","id":3,"name":"Leonardo dicaprio"},
{"age":57,"gender":"Male","id":4,"name":"Brad pitt"},
{"age":64,"gender":"Male","id":5,"name":"Tom hanks"}],
"success":true
}
- Genreal
- Fetches a dictionary of movies
- Request Arguments: None
- Returns: movies array and success boolean value.
- Sample:
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:5000/movies
{
"movies":[
{"id":1,"release_date":"Wed, 01 Jan 2020 00:00:00 GMT","title":"Mulan"},
{"id":2,"release_date":"Wed, 01 Jan 2020 00:00:00 GMT","title":"The Midnight Sky"},
{"id":3,"release_date":"Fri, 01 Jan 2010 00:00:00 GMT","title":"Inception"},
{"id":4,"release_date":"Wed, 01 Jan 2020 00:00:00 GMT","title":"Tenet"},
{"id":5,"release_date":"Tue, 01 Jan 2019 00:00:00 GMT","title":"Joker"}],
"success":true
}
- Genreal
- Removes the specified actor
- Request Arguments: The actor's ID
- Returns: An object than contains a success boolean value and the ID of the deleted actor.
- Sample:
curl -X DELETE -H "Authorization: Bearer $TOKEN" http://127.0.0.1:5000/actors/1
{
"deleted": 1,
"success": true
}
- Genreal
- Removes the specified movie
- Request Arguments: The movie's ID
- Returns: An object than contains a success boolean value and the ID of the deleted movie.
- Sample:
curl -X DELETE -H "Authorization: Bearer $TOKEN" http://127.0.0.1:5000/movies/1
{
"deleted": 1,
"success": true
}
- General
- Creates a new actor
- Request Arguments: None
- Returns: An object that contains a success boolean value and the created actor.
- Sample:
curl http://127.0.0.1:5000/actors -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "{\"name\":\"Brad pitt\",\"age\":\"57\",\"gender\":\"Male\"}"
{
"created":4,
"success":true
}
- General
- Creates a new movie
- Request Arguments: None
- Returns: An object that contains a success boolean value and the created movie.
- Sample:
curl http://127.0.0.1:5000/movies -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "{\"title\":\"Mulan\",\"release_date\":\"2020-01-01\"}"
{
"created":1,
"success":true
}
- General
- Updates the specified actor
- Request Arguments: None
- Returns: An object that contains a success boolean value and the updated actor.
- Sample:
curl http://127.0.0.1:5000/actors/1 -X PATCH -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "{\"name\":\"Angelina jolie\"}"
{
"actor":{
"age":45,
"gender":
"Female",
"id":1,"
name":"Angelina jolie"
},
"success":true}
- General
- Updates the specified movie
- Request Arguments: None
- Returns: An object that contains a success boolean value and the updated movie.
- Sample:
curl http://127.0.0.1:5000/movies/1 -X PATCH -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "{\"title\":\"Home Alone\"}"
{
"movie":{
"id":1,
"release_date":"Thu, 01 Apr 1990 00:00:00 GMT",
"title":"Home Alone"
},
"success":true
}