Casting Agency (The Movie Company) is responsible for making movies and managing and assigning actors to those movies.
This project is done as part of the capstone project in Udacity's Full Stack Developer Nanodegree.
Follow instructions to install the latest version of python for your platform in the python docs
Install dependencies by running:
pip install -r requirements.txtThis will install all of the required packages within the requirements.txt file.
From within the backend directory first ensure you are working using your created virtual environment.
To run the server, execute:
export FLASK_APP=app.py
export FLASK_ENV=development
python app.pyThe API uses Auth0 for 3rd-party authentication of users. These are the Auth0-specific settings:
AUTH0_DOMAIN = 'coffechats.auth0.com'
ALGORITHMS = ['RS256']
API_AUDIENCE = 'capstonecast'
The API has 3 users, each with their own pre-configured permissions:
- Assistant
Credentials:
username: [email protected]
password: Assistant@123
Permissions:
view:actor (Get a list of actors)
view:movie (Get a list of movies)
- Director
Credentials:
username: [email protected]
password: Director@123
Permissions:
view:actor (Get a list of actors)
view:movie (Get a list of movies)
post:actor (Insert a new actor)
delete:actor (Remove an existing actor)
patch:actor (Update an existing actor)
patch:movie (Uodate an existing movie)
- Executive Producer
Credentials:
username: [email protected]
password: Producer@123
Permissions:
view:actor (Get a list of actors)
view:movie (Get a list of movies)
post:actor (Insert a new actor)
post:movie (Insert a new movie)
delete:actor (Remove an existing actor)
delete:movie (Remove an existing movie)
patch:actor (Update an existing actor)
patch:movie (Uodate an existing movie)
https://capstonecast.herokuapp.com
Every API endpoint can be tested by first generating a valid JWT for each user by accessing this link:
The JWTs are valid for 48 hours. Once, you have the access token, use Postman or CURL to hit and test the endpoints.
- Fetches a list of dictionary of all the actors
- Request arguments: None
- Returns: A list of dictionaries of actors which contain key-value pairs about the attributes of the actor
{
"success": true,
"actors": [
{
"id": 1,
"name": "Tom Hanks",
"ager": 48,
"gender": "Male"
},
{
"id": 2,
"name": "Megan Fox",
"ager": 30,
"gender": "Female"
}
]
}
- Fetches a list of dictionary of movies
- Request arguments: None
- Returns: List of dictionaries of movies which contain key-value pairs of information about the movies
{
"success": true,
"movies": [
{
"id": 1,
"title": "Apollo 13",
"release_date": "2005-05-05"
},
{
"id": 2,
"title": "Forrest Gump",
"release_date": "2002-02-02"
}
]
}
- Inserts a new actor in the database
- Request body: name, age and gender
- Returns: true if successfully inserts the actor and returns the updated list of actors
{
"name": "Vin Diesel",
"age": 35,
"gender": "Male"
}
{
"success": true,
"actors": [
{
"id": 1,
"name": "Tom Hanks",
"ager": 45,
"gender": "Male"
},
{
"id": 2,
"name": "Megan Fox",
"ager": 30,
"gender": "Female"
},
{
"id": 3,
"name": "Vin Diesel",
"ager": 35,
"gender": "Male"
}
]
}
- Inserts a new movie in the database
- Request body: title and release_date
- Returns: true if successfully inserts the movie and returns the updated list of movies
{
"title": "The Shawshank Redemption",
"release_date": "1995-03-03"
}
{
"success": true,
"movies": [
{
"id": 1,
"title": "Apollo 13",
"release_date": "2005-05-05"
},
{
"id": 2,
"title": "Forrest Gump",
"release_date": "2002-02-02"
},
{
"id": 3,
"title": "The Shawshank Redemption",
"release_date": "1995-03-03"
}
]
}
- Delete an actor from the list of actors
- Request arguments: <actor_id>
- Returns: true if successfully deleted and id of the deleted actor
{
"success": true,
"delete": "3"
}
- Delete a movie from the list of movies
- Request arguments: <movie_id>
- Returns: true if successfully deleted and id of the deleted movie
{
"success": true,
"delete": "3"
}
- Updates an existing actor in the database
- Request body: name, age and gender
- Returns: true if successfully updates the actor and returns the updated list of actors
{
"name": "Vin Diesel",
"age": 40,
"gender": "Male"
}
{
"success": true,
"actors": [
{
"id": 1,
"name": "Tom Hanks",
"ager": 45,
"gender": "Male"
},
{
"id": 2,
"name": "Megan Fox",
"ager": 30,
"gender": "Female"
},
{
"id": 3,
"name": "Vin Diesel",
"ager": 40,
"gender": "Male"
}
]
}
- Updates an existing movie in the database
- Request body: title and release_date
- Returns: true if successfully updates the movie and returns the updated list of movies
{
"title": "The Shawshank Redemption",
"release_date": "1998-03-03"
}
{
"success": true,
"movies": [
{
"id": 1,
"title": "Apollo 13",
"release_date": "2005-05-05"
},
{
"id": 2,
"title": "Forrest Gump",
"release_date": "2002-02-02"
},
{
"id": 3,
"title": "The Shawshank Redemption",
"release_date": "1998-03-03"
}
]
}
To run the tests, run
python test_app.py

