This project is my last project of full stack web development nano-degree, it was epic as I tried to finish this nano degree in less than 20 days although the estimated time for it is 4 months, it's a demo for a casting agency where you can find actors and movies and directors.
All backend code follows PEP8 style guidelines.
Developers using this project should already have Python3, pip and postgresql installed on their local machines.
From the base directory run
pip install requirements.txt
. All required packages are included in the requirements file.
You have to create a new postgresql database using
createdb capstone
You have to check for the setup.sh
file to make sure that DATABASE_URL matches with your system
To run the application run the following commands:
python manage.py db migrate
python manage.py db upgrade
python manage.py runserver
congratulations, server is running on (http://127.0.0.1:5000/)
In order to run tests navigate to the base dicrectory and run the following commands:
dropdb capstone_test
createdb capstone_test
python test_api.py
- Base URL: This app can only be run locally on (http://127.0.0.1:5000/) It is hosted as a base URL on (https://capstone102.herokuapp.com/)
- Authentication: This version of the application requires authentication, you can login using (https://capstone102.herokuapp.com/login) or (http://127.0.0.1:5000/login) which will redirects you to the auth0 third party authentication to login, you can retreive your token from the url.
There are 3 token in the
setup.sh
file which represent the 3 rules of our app. they may have expired by the time you are cloning this repo.
Errors are returned as JSON objects in the following format:
{
"success": False,
"error": 400,
"message": "bad request"
}
The API will return three error types when requests fail:
- 400: Bad Request
- 404: Resource Not Found
- 422: Not Processable
None
{
"Authorization":"Bearer <assistant token at least>"
}
{
"actors": [
{
"age": 30,
"gender": "male",
"id": 1,
"name": "mohamed"
},
{
"age": 20,
"gender": "female",
"id": 2,
"name": "noha"
},
{
"age": 11,
"gender": "male",
"id": 3,
"name": "mohamed"
},
{
"age": 6,
"gender": "male",
"id": 4,
"name": "ahmed"
}
],
"actors_number": 4,
"success": true
}
{
"name": "name example",
"age" : 30,
"gender": "male"
}
{
"Authorization":"Bearer <director token at least>"
}
{
"created": 5,
"success": true
}
None
{
"Authorization":"Bearer <assistant token at least>"
}
{
"actor": {
"age": 123132,
"gender": ";skdafk;sdf",
"id": 5,
"name": "mohamed"
},
"success": true
}
None
{
"Authorization":"Bearer <director token at least>"
}
{
"deleted": 5,
"success": true
}
{
"name": "name example",
"age" : 30,
"gender": "male"
}
{
"Authorization":"Bearer <assistant token at least>"
}
{
"success": true,
"updated": 2
}
None
{
"Authorization":"Bearer <assistant token at least>"
}
{
"movies": [
{
"id": 1,
"start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
"title": "new moSFASFDvie"
},
{
"id": 2,
"start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
"title": "new moSFASFDvie"
},
{
"id": 3,
"start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
"title": "new moSFASFDvie"
},
{
"id": 4,
"start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
"title": "new moSFASFDvie"
}
],
"movies_number": 4,
"success": true
}
{
"title": "new movie",
"start_time": "2015-11-1"
}
{
"Authorization":"Bearer <producer token at least>"
}
{
"created": 10,
"success": true
}
None
{
"Authorization":"Bearer <assistant token at least>"
}
{
"movie": {
"id": 5,
"start_time": "Sun, 01 Nov 2015 00:00:00 GMT",
"title": "new moSFASFDvie"
},
"success": true
}
None
{
"Authorization":"Bearer <producer token at least>"
}
{
"deleted": 5,
"success": true
}
{
"title": "new movie",
"start_time": "2015-11-1"
}
{
"Authorization":"Bearer <director token at least>"
}
{
"success": true,
"updated": 6
}