-
Notifications
You must be signed in to change notification settings - Fork 0
LuluhAltayyar/Capstone
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
# FSND: Capstone Project ## About This project is simply a workspace for practicing and showcasing different set of skills related with web development. These include data modelling, API design, authentication and authorization and cloud deployment. # FSND: Capstone Project ## Key Dependencies - [Flask](http://flask.pocoo.org/) is a lightweight backend microservices framework. Flask is required to handle requests and responses. - [SQLAlchemy](https://www.sqlalchemy.org/) and [Flask-SQLAlchemy](https://flask-sqlalchemy.palletsprojects.com/en/2.x/) are libraries to handle the lightweight sqlite database. Since we want you to focus on auth, we handle the heavy lift for you in `./src/database/models.py`. We recommend skimming this code first so you know how to interface with the Drink model. - [jose](https://python-jose.readthedocs.io/en/latest/) JavaScript Object Signing and Encryption for JWTs. Useful for encoding, decoding, and verifying JWTS. - [Flask-CORS](https://flask-cors.readthedocs.io/en/latest/#) is the extension we'll use to handle cross origin requests from our frontend server. ## Start Project locally To start and run the local development server: #### Python 3.7 Follow instructions to install the latest version of python for your platform in the [python docs] (https://docs.python.org/3/using/unix.html#getting-and-installing-the-latest-version-of-python) #### Initialize and activate a virtualenv: ``` virtualenv env source env/Scripts/activate ``` #### Install the dependencies: ``` pip install -r requirements.txt ``` ## Running the server To run the server, execute: ``` source setup.sh export FLASK_APP=app.py export FLASK_ENV=development export FLASK_DEBUG=True flask run ``` ## DATA MODELING: #### models.py The schema for the database and helper methods to simplify API behavior are in models.py: - There are two tables created: Movie, and Actor ### Setup Auth0 1. Create a new Auth0 Account 2. Select a unique tenant domain 3. Create a new, single page web application 4. Create a new API - in API Settings: - Enable RBAC - Enable Add Permissions in the Access Token 5. Create new API permissions: - `get:actors` - `get:movies` - `post:actors` - `post:movies` - `delete:actors` - `delete:movie` - `edit:actors` - `edit:movies` 6. Create new roles for: - Casting Assistant - can `get:actors`, `get:movies` - Casting Director - can `get:actors`, `get:movies`, `edit:actors`, `edit:movies`, `post:actors`, `delete:actors` - Executive Producer - can perform all actions 7. Test your endpoints with [Postman](https://getpostman.com). - Register 3 users - assign the Casting Assistant role, Casting Director role, andExecutive Producer role. - Sign into each account and make note of the JWT. ## API Documentation ### Error Handling Errors are returned as JSON objects in the following format: { "error": 404, "massage": "resource not found", "seccess": false } The API will return three error types when requests fail: 400: Bad request 401: invalid header 403: permission error 404: Resource not found 422: Unprocessable 405: "Method Not Allowed" ### Endpoints #### GET/movies - Get all movies - Example response: ``` { "actors": [ { "actors": [ { "age": 34, "gender": "male", "id": 2, "movie_id": 2, "name": "Ali" }, { "age": 34, "gender": "male", "id": 6, "movie_id": 2, "name": "Jon" } ], "id": 2, "release_date": "Fri, 07 Aug 2015 05:00:01 GMT", "title": "Ali Start" } ], "success": true } ``` #### GET/actors - Get all actors - Example response: ``` { "actors": [ { "age": 34, "gender": "male", "id": 2, "movie_id": 2, "name": "Ali" }, { "age": 34, "gender": "male", "id": 6, "movie_id": 2, "name": "Jon" }, { "age": 22, "gender": "female", "id": 7, "movie_id": null, "name": "Sarah" } ], "success": true } ``` #### POST/actors - Creates a new actor. - Example response: ``` { "message": 8, "success": true } ``` #### POST/movies - Creates a new movie. - Example response: ``` { "message": 4, "success": true } ``` #### PATCH/actors/6 - Updates the actor where <actor_id>=6 - Example response: ``` "actor": [ { "age": 33, "gender": "male", "id": 6, "movie_id": 2, "name": "WWW" } ], "success": true, "updated": 6 } ``` #### PATCH/movies/2 - Updates the movie where <movie_id>=2 - Example response: ``` { "actor": [ { "actors": [ { "age": 34, "gender": "male", "id": 2, "movie_id": 2, "name": "Ali" }, { "age": 33, "gender": "male", "id": 6, "movie_id": 2, "name": "WWW" } ], "id": 2, "release_date": "Fri, 07 Aug 2015 05:00:01 GMT", "title": "Ali Start" } ], "success": true, "updated": 2 } ``` #### DELETE /movies/int:movie_id - Delete the movie where <movie_id>=6 - Example response: ``` { "deleted": 6, "success": true } ``` #### DELETE/actors/int:actor_id -Delete the movie where <actor_id>=6 - Example response: ``` { "deleted": 6, "success": true } ``` ## Testing For testing the backend, run the following commands: CEARTE DATABASE capstone_test; python test_app.py ``` $ python test_app.py .{'message': 7, 'success': True} ............... ---------------------------------------------------------------------- Ran 16 tests in 13.557s OK ``` ## Token ### Casting_assistant Token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImR5cEN1b1VCMGFnd3dLU2wyNzBuTyJ9.eyJpc3MiOiJodHRwczovL2Rldi1sdWx1LnVzLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw2MDExNThjNTY4YmYxODAwNjllZDcwOTciLCJhdWQiOiJjYXBzdG9uZUFQSSIsImlhdCI6MTYxMTgxOTc5MSwiZXhwIjoxNjExOTA2MTkxLCJhenAiOiJybWI2WHhTd21HSkRaR3pkMHdpUFhMTTRQNzlaeWhsbyIsInNjb3BlIjoiIiwicGVybWlzc2lvbnMiOlsiZ2V0OmFjdG9ycyIsImdldDptb3ZpZXMiXX0.HmyktvF8d4YwkWdQK78sMJUHv1l_UiNtusxmweYrZN7rrN3mQAeuGzeB8XbXTrjxd_wSI2t7OP7-rM7myUQnBquI3o9H8H_0f8GaEXmxThtHmL1iU8EeCVGrC-Mz5K3cecA_eZPiOB7sD2Tw8950f2aB3UHRwiSHSGdL4NUENUBtcQ4ssdr30vybb05Ho3m3cbIvlDC8TAiY4tqitYvvyFTWDwRgHeDP7z3cYeX5DCzqn-CxebrmaHOsb60UgVtT7VWlgU3tULA2GZLu07VR0m3bP-SzIDYSCzdHukUmZp7bhQX0BFlykoy8eWUKyKAgmRV4Si_iqeFa0r0HO58kCw ### Casting_director Token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImR5cEN1b1VCMGFnd3dLU2wyNzBuTyJ9.eyJpc3MiOiJodHRwczovL2Rldi1sdWx1LnVzLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1ZmI1MDVlMzE4NjZiNDAwNjg2N2YyZjIiLCJhdWQiOi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wiZ2V0Om1vdmllcyIsInBvc3Q6YWN0b3JzIiwicG9zdDptb3ZpZXMiXX0.PJCvZYTztZzTYDODM4_3uie09yjszU2fBBLNX9aJfWXj46y64uR_i5T58hORoIvQ4LmtjxzSjH94ohzchm1zcsqnED-9B9ltx70I8L3c5mltt5dLy-_Nl-PA5NLCG0pkZr_xD0WzMsDvGhm6beKegrWCyjblwcU7hkeCYY7jhi_LUa5JEoa-x28yeTgd7nQHIGKGAPPAxiZRVlxNrzuxvfqA1VA9LVmTYglzU9MmXoQrGTOfkqydWMb7zYSZsXidOBwxZWxmBznW8_qeGD_I6_J31ycubKXuqO_xkBK3jNWoQg4zdIoiRJnGdeelFAHC0PaX23Rwy1XkjH_rOx5DeA ## Heroku ``` https://hidden-mesa-84288.herokuapp.com/ ```
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published