A simple read-only Flask API for serving Dhammapada chapters and verses from a local SQLite database.
On first run, the application creates the database and imports data from dhammapada.json.
This project:
- uses
Flaskto expose HTTP endpoints - uses
Flask-SQLAlchemywith SQLite for storage - uses
Flask-Marshmallowfor JSON serialization - automatically loads Dhammapada data from
dhammapada.json
The current API is read-only and focused on retrieving chapters and verses.
dhammapadaAPI/
|-- app.py
|-- dhammapada.json
|-- README.md
`-- instance/
`-- dhammapada.db
Install Python 3.10+ and these packages:
pip install flask flask-sqlalchemy flask-marshmallow marshmallow-sqlalchemyFrom the project root:
python app.pyThe app will start a local development server, typically at:
http://127.0.0.1:5000
When the application starts:
- it creates the SQLite database if it does not already exist
- it checks whether the
chaptertable has data - if empty, it imports chapters and verses from
dhammapada.json
The database file is created at:
instance/dhammapada.db
Returns all chapters with their verses.
Returns all chapters with their verses.
Returns a single chapter by database id.
Example:
/chapters/1
Returns all verses ordered by chapter and verse number.
Returns a single verse by database id.
Example:
/verses/1
Returns all verses for a specific chapter using the chapter's database id.
Example:
/chapters/1/verses
Example chapter object:
{
"id": 1,
"number": 1,
"title": "Chapter title",
"verses": [
{
"id": 1,
"verse_number": 1,
"text": "..."
}
]
}The source text is stored in:
Its structure is:
{
"chapters": [
{
"number": 1,
"title": "Chapter title",
"verses": [
{
"verse_number": 1,
"text": "Verse text"
}
]
}
]
}- The current routes use database
id, not chapternumberorverse_number. - Running with
debug=Trueis suitable for development only. - If you change
dhammapada.jsonafter the database is already populated, the app will not re-import automatically unless the database is cleared first.
If you want to rebuild the database from the JSON file, delete:
instance/dhammapada.db
Then run:
python app.py- add search by chapter number and verse number
- add filtering and pagination
- add a
requirements.txt - add tests
- add deployment instructions