Simple Flask app that manages a small book collection using SQLAlchemy with an SQLite database.
- Python 3.8+
- pip
- (optional) virtualenv
- Install dependencies:
pip install -r requirements.txt
- Create and activate a virtual environment (optional):
- python -m venv .venv
- source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
Start the dev server:
python main.py
Open http://127.0.0.1:5000 in a browser.
/- Home: list all books (templates/index.html)/add- Add a new book (GET/POST)/update/<int:book_id>- Update book rating (GET/POST)/delete/<int:book_id>- Delete a book (POST only)
Database file books-collection.db is created automatically on first run.
- The delete route accepts POST only. The index template uses a small inline form with method="post" and a submit button to issue the correct POST request. An
<a>link cannot issue POST by itself. - For production, add CSRF protection (e.g., Flask-WTF) before exposing POST actions.
- To change behavior (not recommended), the route can be changed to accept GET, or JavaScript can issue a POST while preserving link styling.
Templates are in the templates/ folder: index.html, add.html, update.html.
Generated by the project owner.