This projects provides an API backend for a casting application with CRUD actions for movies and actors and simply manage actors assigned to movies
Follow instructions to install the latest version of python for your platform in the python docs
We recommend working within a virtual environment whenever using Python for projects. This keeps your dependencies for each project separate and organaized. Instructions for setting up a virual enviornment for your platform can be found in the python docs
Once you have your virtual environment setup and running, install dependencies by naviging to the /
directory and running:
pip install -r requirements.txt
-
Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
-
SQLAlchemy is the Python SQL toolkit and ORM we'll use handle the lightweight sqlite database. You'll primarily work in app.py and can reference models.py.
-
Flask-CORS is the extension we'll use to handle cross origin requests from our frontend server.
- Base URL: Currently this application is only hosted locally. The backend is hosted at
http://127.0.0.1:5000/
- Authentication: Authentication is based on JWT Tokens with role based authentication.
- Casting assistant: A casting assistang can view actors and movies
- Casting director: A casting director extends the casting assistant's permissions by adding and deleting actors from the database and can also change actors and movies
- Executive Producer: The executive producer extends the casting director's permissions by adding or deleting movies from the database
Errors are returned as JSON in the following format:
{
"success": false,
"error": 404,
"message": "Resource not found"
}
The API will return two types of errors:
- 404 – Resource not found
- 422 – Unprocessable Entity
- 400 - Bad request
- 405 - Method not found
- 500 - Internal Server error
- 401 - Unauthorized
- 4ß3 - Forbidden
Returns a list of movies
{
"success": true,
"movies": [
{
"actors": [],
"id": 1,
"release_date": "Tue, 04 Dec 2012 00:00:00 GMT",
"title": "Title"
},
{
"actors": [1],
"id": 2,
"release_date": "Tue, 04 Dec 2012 00:00:00 GMT",
"title": "Title2"
}
]
}
Returns a list of movies
{
"success": true,
"movie": {
"actors": [],
"id": 1,
"release_date": "Tue, 04 Dec 2012 00:00:00 GMT",
"title": "Title"
}
}
Returns a list of movies
{
"success": true,
"movie": {
"actors": [],
"id": 1,
"release_date": "Tue, 04 Dec 2012 00:00:00 GMT",
"title": "Title"
}
}
Deletes a movie by id
{
"success": true,
"deleted": 12
}
Returns a list of actors
{
"success": true,
"actors": [
{
"age": 30,
"gender": "male",
"id": 1,
"name": "Name"
},
{
"age": 50,
"gender": "male",
"id": 1,
"name": "Name2"
}
]
}
Returns a list of actors
{
"success": true,
"actor": {
"age": 30,
"gender": "male",
"id": 1,
"name": "Name"
}
}
Returns a list of actors
{
"success": true,
"actor": {
"age": 30,
"gender": "male",
"id": 1,
"name": "Name"
}
}
Deletes a actor by id
{
"success": true,
"deleted": 12
}
Tests are prefixed with numbers to sort their test execution
Script for running tests:
python test_app.py
The application is hosted by heroku under the url: 'heroku app'