Skip to content
Keep track of what you read.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
static
.gitignore
LICENSE
Pipfile
Procfile
app.py
index.html
readme.org
screenshot.png
utils.py

readme.org

Book Keeper

Book Keeper lets you keep track of what you’re currently reading, what you want to read next, and what have finished reading. You can think of it like a todo-list for books.

Safari doesn’t seem to handle DELETE requsets properly, so I would recommend using Firefox or Chrome.

  • Framework: Bottle.py
  • Security: Basic Auth + bcrypt (OAuth and CSRF is out of the project scope)
  • Deployment: Heroku + PostgreSQL

There is a live demo hosted on Heroku.

Development

# heroku will provide this as an environment variable
export DATABASE_URL=postgresql://[user[:password]@][netloc][:port][/dbname]

# setup virtualenv and install dependencies
pipenv install
pipenv run app.py 8080

Deploy with: git push heroku master

API

DataTypes:

  • Book Object: {"title": "", "author": "", ...}
  • Book Status: {"status": "now|next|done"}

Demo Accounts:

  • username: guest, password: sixtimesnine
  • username: admin, password: lifeuniverse

/book

GET (200)

Fetch all books from your library:

curl -u username:password localhost:8080/book
>>> {"now": [...], "next": [...], "done": [...]}

POST (201)

Add a new book to your library:

curl -H "Content-Type: application/json" -X POST -u username:password \
localhost:8080/book --data '{"book": {"title": "Ubik", "author": "Philip K. Dick"}, "status": "now"}'
>>> {"book_id": 13, "book": {"title": "Ubik", "author": "Philip K. Dick"}, "status": "now"}

/book/{bookID}

GET (200)

Fetch a specific book using its ID:

curl -u username:password localhost:880/book/42
>>> {"book_id": 42, "book": {"title": "1984", "author": "George Orwell"}, "status": "next"}

PATCH (200)

Update some information about a book in your library:

# [ { "op": "status", "value": "now|next|done" },
#   { "op": "book", "value": {...} } ]
#
curl -H "Content-Type: application/json" -X PATCH -u username:password \
localhost:8080/book/42 --data '[{"op":"status","value":"done"}]'
>>> {"updated": [{"book_id": 42, "book": {"title": "1984", "author": "George Orwell"}, "status": "done"}]}

DELETE (204)

Remove a book from your library:

curl -x DELETE -u username:password localhost:8080/book/42
>>>

/reset

Reset the database and add populate it with some demo data. Only the admin user can do this.

curl -u admin:password localhost:8080/reset
>>> {"success": "Database initialized."}

Errors

Example error object:

curl -u username:password localhost:8080/book/42
>>> {"error": "Exception('Book Not Found',)"}

Screenshot

screenshot.png

You can’t perform that action at this time.