This project was built to test my knowledge of writing API endpoints and authentication
All backend code follows PEP8 style guidelines.
Developers using this project should have python3 and pip installed on their local machines
From the backend folder run pip install -r requirements.txt
All required packages are included in the requirements file.
To set up the database:
createdb Casting -U postgres
To run the application run the following commands:
Set FLASK_APP=app.py
Set FLASK_ENV=development
python -m flask run
These commands put the application in development. Working in development mode shows an interactive debugger in the console and restarts the server whenever changes are made. if running locally on linux look for commands in the Flask documentation.
The application on http://127.0.0.1:5000
by default and on https://casting101.herokuapp.com/
In order to run tests navigate to the backend folder and run the following commands:
dropdb casting_test -U postgres
createdb casting_test -U postgres
psql -U postgres casting_test < casting.pgsql
python test_app.py
The first time you run the tests, omit the dropdb command. All tests are kept in that file and should be maintained as updates are made to app functionality.
-
Base url: At present this app can be at "https://casting101.herokuapp.com/"
-
Authentication: you need to signup/login from this page
https://dev-g-z09scw.us.auth0.com/authorize?audience=Casting&response_type=token&client_id=Rz6YyS9V9I8ghwu3fY0ark7zACP5CHNQ&redirect_uri=https://casting101.herokuapp.com/actors
Erros are returnd as JSON objects in the following format:
{
"success": False,
"error": 400,
"message": "bad request"
}
- 404: resource not found
- 422: unprocessable
- 400: bad request
- 405: method not allowed
The endpoints samples can be run throught postman
- General:
- Returns a list of actors and success value
- Sample: https://casting101.herokuapp.com/actors
{
"actors": [
{
"age": "24",
"gender": "male",
"id": 1,
"name": "ahmed"
},
{
"age": "23",
"gender": "male",
"id": 2,
"name": "mohammed"
}
],
"sucess": true
}
- General:
- Returns a list of movies, success value, and total number of movies
- Results are paginated in groups of 10. Include a request argument to choose page number, starting from 1.
- Sample: curl https://casting101.herokuapp.com/movies
{
"movies": [
{
"date": "01/15/2012",
"id": 1,
"title": "interstaller"
}
],
"success": true,
"total_movies": 1
}
- General:
- Creates a new actor using the name, age, and gender. Returns the created actor, success value and total actors.
- Sample: POST: https://casting101.herokuapp.com/actors
{
"actors": [
{
"age": "23",
"gender": "male",
"id": 1,
"name": "ahmed"
},
{
"age": "23",
"gender": "male",
"id": 2,
"name": "mohammed"
}
],
"created": {
"age": "23",
"gender": "male",
"id": 4,
"name": "khalid"
},
"success": true
}
- General:
- Creates a new movie using the title and date. Returns the created movie, success value and total movies.
- Sample: POST: https://casting101.herokuapp.com/movies
{
"created": {
"date": "01/15/2012",
"id": 1,
"title": "interstaller"
},
"movies": [
{
"date": "01/15/2012",
"id": 1,
"title": "interstaller"
}
],
"success": true
}
-
General:
- Deletes the actor of the given ID if it exists. returns the success value, and the deleted actor.
-
Sample: DELETE: https://casting101.herokuapp.com/actors
{
"delete": {
"age": "23",
"gender": "male",
"id": 10,
"name": "mohammed"
},
"success": true
}
-
General:
- Deletes the movie of the given ID if it exists. returns the success value, and the deleted movie.
-
Sample: DELETE: https://casting101.herokuapp.com/movies
{
"delete": {
"date": "01/15/2012",
"id": 1,
"title": "interstaller"
},
"success": true
}
-
General:
- Edit the actor of the given ID if it exists. returns the success value, and the edited actor.
-
Sample: PATCH: https://casting101.herokuapp.com/actors
{
"actors": {
"age": "25",
"gender": "male",
"id": 2,
"name": "khalid"
},
"success": true
}
-
General:
- Edit the movie of the given ID if it exists. returns the success value, and the edited movie.
-
Sample: PATCH: https://casting101.herokuapp.com/movies
{
"movies": {
"date": "03/25/2006",
"id": 3,
"title": "catch me if you can"
},
"success": true
}
Can view actors and movies. GET /movies, GET /actors
All permissions a Casting Assistant has and… Add or delete an actor from the database Modify actors or movies. GET /movies, GET /actors, POST /actors, PATCH /actors, PATCH /movies, DELETE /actors
All permissions a Casting Director has and… Add or delete a movie from the database GET /movies, GET /actors, POST /actors, PATCH /actors, PATCH /movies, DELETE /actors, POST /movies, DELETE /movies
https://casting101.herokuapp.com
Yours truly, Mohammed Alessa
The awesome team at udacity
setup.sh has tokens that can be used to test different users using postman bearer token