-- coding: utf-8 --
Home page https://github.com/clach04/webook_server
Table of contents generated with markdown-toc
This is either:
Basic ebook server that doesn't require a database.
Given a directory of (possibly directories of) ebooks serve a web (http) interface of the files and automatically convert to the desired format (incomplete examples; mobi, epub, fb2, html, txt, rtf, etc.). The format is specified in the URL and browsing is supported. This works great with a web browser (including the Amazon Kindle Experimental Web Browser) and OPDS client like KOReader.
book
would match a file named "mybook.txt" and a directory called "books"Comes with:
The closest equivilents of this tool are KindleGate which only supports conversion to mobi and https://github.com/dubyte/dir2opds.
Also take a look at:
Either use Operating System packages or Python packages
For Python 2.x deployment:
sudo apt install calibre
For Python 3.x deployment (with calibre ebook-convert exe - likely Python2):
sudo apt install calibre
NOTE Currently relies on Calibre ebook-convert (not documented in the Python dependency install notes below).
ONLY needed for the web browser version, not needed for OPDS
If installing/working with a source checkout issue:
pip install -r requirements.txt
cp example_config.json config.json
# Optional; edit config.json with "ebook_dir" (defaults to ./ if omitted) and "temp_dir" (will use OS environment variable TEMP if omitted, if that's missing system temp location) location
python webook_server.py
Then open a browser to http://localhost:8080/... or issue:
curl http://localhost:8080/....
sample_reading_media
Create a (or edit existing) config file, for example named sample_reading_media.json
{
"ebook_dir": "sample_reading_media"
}
if setting tmp dir, mkdir -p /tmp/ebookserver/....
Run the server with the config file:
python webook_server.py sample_reading_media.json
Open Web browser to http://127.0.0.1:8080/ and browse around, for example download
Systemd service (e.g. for Raspbian).
For more information see:
NOTE directory name for ExecStart
and WorkingDirectory
in webook.service
.
Install
# Potententially edit service; ExecStart, WorkingDirectory, User
# Review config file
sudo cp scripts/webook.service /etc/systemd/system/webook.service
sudo chmod 644 /etc/systemd/system/webook.service
sudo systemctl enable webook.service
Usage
sudo systemctl stop webook.service
sudo systemctl start webook.service
sudo systemctl restart webook.service
sudo systemctl status webook.service # status and recent logs
sudo systemctl status webook.service -n 100 # show last 100 log entries
journalctl -u webook.service # show all logs
systemctl list-unit-files --state=enabled | grep webook
NOTE if changing service files, e.g. adding Environment
, restart config (not just specific service):
sudo systemctl daemon-reload
sudo systemctl restart webook.service
./
)http://123.45.67.89:8080
temp_dir
in json configebook_dir
in json configconfig.port
config.host
Known to work under Linux with
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS" NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Armbian 21.08.6 Focal" VERSION_ID="20.04"
With:
Using the OS packages for Python and Calibre.
For testing. By default cURL will be detected by webook_opds_server.py as an OPDS client (rather than as a web browser), this can be influenced via the http accept header.
curl -v --header "ACCEPT: /" # NOTE this happens to be the default so this is not actually needed curl -v --header "ACCEPT: text/html" # convince OPDS server this client is a web browser