Hosted Here
Finsl project on the Udacity
- Database with postgres and sqlalchemy
- API with Flask
- Test Driven Development Unittest
- Authentication Auth0
- Deployment on
Render Cloud Platform
- If you havent already, Download the project locally
git clone https://github.com/AyishaAlli/Casting-agency.git
cd Casting-agency
- Install frontend dependencies
npm install
- Initialize and activate a virtualenv using:
python3.10 -m venv env
source env/bin/activate
Note
- In Windows, the
env
does not have abin
directory. Therefore, you'd use the analogous command shown below:
source env/Scripts/activate
- Install the dependencies:
pip3 install -r requirements.txt
- Setup Environment Variables The env variables can be set running setup.sh. Before running the script set the database URI string to your local database Add your details to line ??????? (Replace USERNAME with your postgres user and add a password if you have one. if you dont have a password please just remove the word 'PASSWORD'):
DATABASE_URI = 'postgresql://USERNAME:PASSWORD@localhost:5432/casting_agency' # e.g. postgresql://ayishaalli:123@localhost:5432/casting_agency
Then run the below to set the variables
sudo chmod +x setup.sh
source ./setup.sh
- Create Database:
Please make sure you have postgreSQL installed To download please see https://www.postgresql.org/download/
First, start your PostgreSQL database server by running:
sudo service postgresql start
OR
brew services start postgresql
- create the database:
createdb casting_agency
- Uncomment lines 22 and 23 in app.py (as seen below) to create tables then comment back out AFTER step 8. Can be uncommented again to reset the database tables
with app.app_context():
db_drop_and_create_all()
- Run App
flask run --reload
The API will return three types of errors:
- 404 – resource not found
- 422 – unprocessable
- 401 - Unauthorized
- 400 - bad request
- 500 - internal server error
- 403 - Forbidden
-
General: Return list of actors in Database
-
Sample:
curl -L -X GET 'vast-stream-21858.herokuapp.com/actors' \ -H 'Authorization: Bearer Assisant_Token'
{ "actors": [ { "age": 25, "gender": "male", "id": 3, "name": "mohammad" } ], "success": true }
-
General: Return list of movies in Database
-
Sample:
curl -L -X GET 'vast-stream-21858.herokuapp.com/movies' \ -H 'Authorization: Bearer Assisant_Token'
{ "movies": [], "success": true }
-
General:
- Create actor using JSON Request Body
- Return ID of created actor
-
Sample:
curl -X POST 'vast-stream-21858.herokuapp.com/actors' \ -H 'Authorization: Bearer Director_Token' \ -H 'Content-Type: application/json' \ --data-raw '{ "name":"mohammad", "age":15, "gender":"male" }'
{ "created_id": 4, "success": true }
-
General:
- Create movie using JSON Request Body
- Return ID of created movie
-
Sample:
curl -X POST 'vast-stream-21858.herokuapp.com/movies' \ -H 'Authorization: Bearer Executive_Token' \ -H 'Content-Type: application/json' \ --data-raw '{ "title":"The Mud", "release_date" : "10-10-2016" }'
{ "created_id": 2, "success": true }
-
General:
- Modify actor given id in URL provided the information to update
-
Sample:
curl -X PATCH 'vast-stream-21858.herokuapp.com/actors/3' \ -H 'Authorization: Bearer Director_Token' \ -H 'Content-Type: application/json' \ --data-raw '{ "name" : "mohammad", "age" : 25 }'
{ "actor": { "age": 25, "gender": "male", "id": 3, "name": "mohammad" }, "success": true }
- General:
- Modify movie given id in URL provided the information to update
- Sample:
curl -X PATCH 'vast-stream-21858.herokuapp.com/movies/2' \ -H 'Authorization: Bearer Director_Token' \ -H 'Content-Type: application/json' \ --data-raw '{ "title":"Terminator", "release_date":"10/19/2019" }'
-
General: Delete an actor given id in URL
-
Sample:
curl -X DELETE 'vast-stream-21858.herokuapp.com/actors/3' \ -H 'Authorization: Bearer Executive_Token'
{ "deleted_id": 3, "success": true }
-
General: Delete movie given id in URL
-
Sample:
curl -X DELETE 'vast-stream-21858.herokuapp.com/movies/2' \ -H 'Authorization: Bearer Executive_Token'
{ "deleted_id": 2, "success": true }
TROUBLESHOOTING
If the error 'can be resolved' comes up when you hover over imports run
which python
Copy and paste the path into your python interpreter (in your command palette type 'python:select interpreter')
Roles:
Casting Assistant Can view actors and movies
assistant@gmail.com
testing12345!
Casting Director All permissions a Casting Assistant has and… Add or delete an actor from the database
castingdirector@gmail.com
testing12345!
Modify actors or movies Executive Producer All permissions a Casting Director has and… Add or delete a movie from the database
execprod@gmail.com
testing12345!