/Flask-Capstone

Udacity Nanodegree 5th project

Primary LanguagePython

FSND Casting Agency Capstone Bollywood project

capstone project for the udacity full stack nanodegree program.

Heroku link: (https://mukul-fsnd-capstone.herokuapp.com/)

Getting Started

Installing Dependencies

Python 3.7

Follow instructions to install the latest version of python for your platform in the python docs

PIP Dependencies

Once you have your virtual environment setup and running, install dependencies by naviging to the /backend directory and running:

pip install -r requirements.txt

This will install all of the required packages we selected within the requirements.txt file.

Key Dependencies
  • 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 api.py and can reference models.py.

  • Flask-CORS is the extension we'll use to handle cross origin requests from our frontend server.

Running the server

To run the server, execute:

export FLASK_APP=api.py
export FLASK_ENV=debug
flask run --reload

Casting Agency Specifications

The Casting Agency models a company that is responsible for creating movies and managing and assigning actors to those movies. You are an Executive Producer within the company and are creating a system to simplify and streamline your process.

Models

Movies with attributes contain title, year, director and genre Actors with attributes name, role and gender

Environment Variables

In the .env file, the JWT token for each User Role

  • CASTING_ASSISTANT
  • CASTING_DIRECTOR
  • EXECUTIVE_PRODUCER

Roles

Casting Assistant

  • GET:actors
  • GET:movies

Casting Director

All permissions a Casting Assistant has
  • POST:actor
  • DELETE:actor
  • PATCH:actor
  • PATCH:movie

Executive Producer

All permissions a Casting Director has
  • POST:movie
  • DELETE:movie

Endpoints

GET '/actors'

reponse = {
success: True,
actors: [
          {
            name: "Salman Khan",
            role: "cast",
            gender: "male",
          },
          {
            name: "Aamir Khan",
            role: "cast",
            gender: "male",
          }
        ]
  }


POST '/actors'

payload = {
            name: "Salman Khan",
            role: "cast",
            gender: "male",
          }
response = {
  success: True,
  actor:{  
    name: "Kelvin Hart",
    role: "cast",
    gender: "male"
   }
}

PATCH '/actors/<int:actor_id>'

params = <int:actor_id>

response = {
  success: True,
  actor:{
            name: "Salman Khan",
            role: "cast",
            gender: "male",
          }
}

DELETE '/actors/<int:actor_id>'

params = <int:actor_id>

response = {
  success: True,
  delete: actor_id
}

GET '/movies'

response = {
success: True,
movies: [
          {
            title: "Dabangg",
            year: 2019,
            director: "Kabir Khan",
            genre: "fiction"
          },
          {   
            title: "PK",
            year: 2019,
            director: "Rajkumar hirani",
            genre: "fiction"
          }
        ]
  }


POST '/movies'

payload = {   
            title: "PK",
            year: 2019,
            director: "Rajkumar hirani",
            genre: "fiction"
          }
response = {
  success: True,
  movie:{   
            title: "PK",
            year: 2019,
            director: "Rajkumar hirani",
            genre: "fiction"
          }
}

PATCH '/movies/<int:movie_id>'

params = <int:movie_id>

response = {
success: True,
movies: {   
            title: "PK",
            year: 2019,
            director: "Rajkumar hirani",
            genre: "fiction"
          }
        
  }


DELETE '/movies/<int:movie_id>'


params = <int:movie_id>

response = {
  success: True,
  delete: movie_id
} 

Testing

To run the tests, cd into /src and run in your terminal

python test.py