Skip to content

Read passages from the bible using curl or HTTPie! All output to the terminal colored using ANSI Escape Codes.

License

Notifications You must be signed in to change notification settings

connorricotta/curl_bible

Repository files navigation

Curl Bible

MIT License Code Style Autopep8 Docker Pulls

Screenshot 1

Read passages from the bible using curl or HTTPie! All output to the terminal colored using ANSI Escape Codes.

Examples:

  curl "bible.ricotta.dev/John:3:15-19?options=length=35,width=50"

  curl "bible.ricotta.dev/?book=John&chapter=3&verse=15-19"

  curl "bible.ricotta.dev/John/3/15-19?version=YLT&text_only=True"

Installation

  1. Ensure Podman-compose is installed. docker-compose does also work, but has [security issues].

  2. Copy the compose file from the repo wget https://github.com/connorricotta/curl_bible/blob/main/compose.yaml

  3. Copy .env.sample and rename to .env wget https://github.com/connorricotta/curl_bible/blob/main/.env.sample && mv .env.sample .env

  4. Run the configuration script to generate a random password for both the root and regular database users. ./install.sh

  5. Start up the program.

    • The Database might take ~15 seconds to become ready for queries. docker-compose up -d
Show manual installation instructions
  1. Ensure Python3, pip, and pipenv are installed.
  2. Change directory into the python directory and create a pipenv environment.
cd python
pipenv shell
  1. Start up the backend server with this command (more options can be found here)
gunicorn --bind 0.0.0.0:10000 wsgi:app --log-level warning --error-logfile error.log --capture-output --log-config logging.conf
  1. Ensure that mariadb is installed and you are able to connect to it.
  2. Open up mariadb and enter the following commands

    The words in {braces} should be replaced with different values

CREATE USER 'bibleman'@'localhost' IDENTIFIED BY '{newpassword}'
CREATE DATABASE IF NOT EXISTS bible;
GRANT ALL PRIVILEGES ON bible.* TO 'bibleman'@'localhost';
FLUSH PRIVILEGES;
exit;
  1. Import the SQL dump into the bible database.
sudo mysql -u root -p bible < {path to directory}/curl_bible/sql/bible-mysql.sql
  1. Modify python/.env to make sure MYSQL_PASSWORD and DB_PORT match your current configuration.
MYSQL_ROOT_USER=root
MYSQL_ROOT_PASSWORD={changeme123}
MYSQL_USER=bibleman
MYSQL_PASSWORD={changemealso}
MYSQL_DATABASE=bible
DB_HOST=bible_db
DB_PORT=3306

Query Options

There are three endpoints that can be used to query the database:

  1. Full Verse Query (/Book:Chapter:Verse)
curl bible.ricotta.dev/John:3:15-20
  1. Slash Query (/Book/Chapter/Verse)
curl bible.ricotta.dev/John/3/15-20
  1. Parameter Query (/?book=Book&chapter=Chapter&verse=Verse)

curl "bible.ricotta.dev?book=John&chapter=3&verse=15-20"

These endpoints can be queried with the following formats.

Query Types Examples
Single Verse curl bible.ricotta.dev/John:3:15
curl bible.ricotta.dev/John/3/15
curl "bible.ricotta.dev/?book=John&chapter=3&verse=15"
Multiple Verses curl bible.ricotta.dev/John:3:15-20
curl bible.ricotta.dev/John/3/15-20
curl "bible.ricotta.dev/?book=John&chapter=3&verse=15-20"
Entire Chapters curl bible.ricotta.dev/John:3
curl bible.ricotta.dev/John/3
curl "bible.ricotta.dev/?book=John&chapter=3"

Options

The length, width, and output color of the returned book can be controlled by appending options= or o= to the query. The full list of options are:

  1. length or l:
    • Set the number of columns in the returned book.
    • Default Value: 20
  2. width or w:
    • The size of each row in the returned book.
    • Default Value: 80
  3. text_only or t:
    • Only return the text, not the book.
    • Default Value: False
  4. color_text or c:
    • Include ANSI Escape Codes in the output.
    • Default Value: True
  5. verse_number or b:
    • Display the associated verse numbers in superscript.
    • Default value: False
  6. version or v:

Examples:

curl "bible.ricotta.dev/John/3/15-20?options=length=25,color_text=False,version=ASV"

curl "bible.ricotta.dev/John/3/15-20?length=25&color_text=False&version=ASV"

curl "bible.ricotta.dev/John/3/15-20?l=&w=50&c=False&v=ASV"

These options can be displayed with the command

curl bible.ricotta.dev/help

Versions

There are five translation/versions that can be queried by this program. These versions are taken from https://github.com/scrollmapper/bible_databases

  1. ASV (American Standard Version)
  2. BBE (Bible in Basic English)
  3. KJV (King James Version)
  4. WEB (World English Bible)
  5. YLT (Young's Literal Translation)

Examples:

curl bible.ricotta.dev/John/3/15-20?version=ASV

curl "bible.ricotta.dev?book=John&chapter=3&version=ylt"

These options can be displayed with the command

curl bible.ricotta.dev/versions

About

Read passages from the bible using curl or HTTPie! All output to the terminal colored using ANSI Escape Codes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published