NOTE: This is a quick and dirty example project using a RESTful API and React!
A simple app to track movie collections.
The application is broken up in two pieces, the server-side api written using Flask and a client-side SPA written using React.
- Install
cd api && pipenv install
- Activate env
pipenv shell
- Load up the DB
python db.py
# Optionally load up some seed data
sqlite3 movies.db < seed.sql
- Run
export FLASK_ENV=development # Optional
FLASK_APP=api:create_app flask run
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
- Install
cd app
yarn install
- Run
yarn start