tsoporan / movie_catalogue

A simple app to track movie collections

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MovieCatalogrrr

NOTE: This is a quick and dirty example project using a RESTful API and React!

A simple app to track movie collections.

Image of MovieCatalogrrr


Set up

The application is broken up in two pieces, the server-side api written using Flask and a client-side SPA written using React.

API

Requirements
  1. Install
cd api && pipenv install
  1. Activate env
pipenv shell
  1. Load up the DB
python db.py

# Optionally load up some seed data
sqlite3 movies.db < seed.sql
  1. Run
export FLASK_ENV=development # Optional
FLASK_APP=api:create_app flask run
Examples

The API can currently only return a JSON response, ex:

λ ~/projects/movie_catalogue/ master* curl localhost:5000/movies/1
{
  "actors": [
    {
      "id": 3,
      "name": "Jake Gyllenhaal"
    }
  ],
  "created_at": 1533516337,
  "genres": [
    {
      "id": 4,
      "name": "thriller"
    },
    {
      "id": 5,
      "name": "sci-fi"
    }
  ],
  "id": 1,
  "rating": null,
  "seen": 0,
  "title": "Donnie Darko"
}

Some examples of querying with cURL:

# See all movies
curl "localhost:5000/movies"

# Apply some filters
curl "localhost:5000/movies?title=John"
curl "localhost:5000/movies?limit=2"
curl "localhost:5000/movies?genre=action"
curl "localhost:5000/movies?genre=action&limit=1"

curl localhost:5000/genres
curl localhost:5000/actors

# Adding a movie
curl -X POST -d "title=Sharknado" http://localhost:5000/movies # Try again and notice error response
curl -X POST -d "title=John%20Wick%202&genres=action&actors=Keanu%20Reeves" http://localhost:5000/movies # With genre and actor
curl -X POST -d "title=Speed&genres=action,crime&actors=Keanu%20Reeves,Sandra%20Bullock" http://localhost:5000/movies # Multiple

# Use movie ID to query
curl http://localhost:5000/movies/1 # Your ID

# You can also POST to create genres and actors

SPA

Requirements
  1. Install
cd app
yarn install
  1. Run
yarn start

About

A simple app to track movie collections

License:GNU General Public License v3.0


Languages

Language:Python 50.2%Language:JavaScript 43.4%Language:HTML 6.4%