
Tested with Dependancy:Version
=======================
python3:3.10.6-1~22.04
python3-flask:2.0.1-2ubuntu1
sqlite3:3.37.2-2ubuntu0.1
libhunspell-dev:1.7.0-4build1
python3-hunspell:0.5.5-2build6
uwsgi-core:2.0.20-4
uwsgi-plugin-python3:2.0.20-4
apache2:2.4.52-1ubuntu4.2
python3-requests:2.25.1+dfsg-2

However, most up to date packages should be fine.

Installation
======
This software expects to be installed at /opt/kjv-api/ (for uwsgi use on a reverse proxy)
If you change this installation directoy, make sure kjv-api.sh has its path updated.
This installation method is intended to play nice among other Virtual Hosts

0. Install dependancies listed at the head of this document.
 - I used ubuntu repositories, but many can be installed via pip in a venv. it
   would probably be a better way than with system repositories. uwsgi however is
   a system package, I'm pretty sure.
   - If you use pip/venv, you will need to modify the kjv-api.sh script to activate
     the venv before executing it, I'm pretty sure.
 - You may substitute the webserver for one of your choice, as long as it's capable
   of reverse proxy. Do not run it with the flask development server or serve directly
   as a uswgi thing.

1. For security, create a new user with the name 'kjv'
 - sudo useradd -r -s /bin/false kjv

2. Change ownership of the /opt/kjv-api/ folder to the kjv user
 - sudo chmod -R kjv:kjv /opt/kjv-api/

3. Test the software runs by running kjv-api.sh as a non-root user (preferably as kjv user)
   and that you are able to query it locally.
 - term1. sudo -Hu kjv ./kjv-api.sh
 - term2. curl -XGET 127.0.0.1:1611/random

4. If you intend to set up the software as a persistant service, copy kjv-api.service from
   the install folder to /etc/systemd/system/kjv-api.service if you're using systemd.
 - sudo cp /opt/kjv-api/install/kjv-api.service /etc/systemd/system/
 - sudo systemctl enable kjv-api.service
 - sudo systemctl start kjv-api.service

5. Configure your webserver as a reverse proxy to point to 127.0.0.1:1611 for where you
   wish to have the api hosted.
 - A sample configuration for apache is provided in the install folder.
 - It is up to you to use https or not, but if you know nginx or haproxy you should be able
   to set up local proxying to the WSGI server that runs the flask.
 - There are WSGI modules for apache avaliable, which may be better for larger scaled
   deployments, but http proxying to the local uwsgi served flask works fine for smaller uses.
