dariosalvelli / py-clave

A prototype implementation of a set of public RESTful APIs meant to enable clients to retrieve metadata and contents from a bunch of digital publications in EPUB2 format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

py-clave

A prototype implementation of a set of public RESTful APIs meant to enable clients to retrieve metadata and contents from a bunch of digital publications in EPUB2 format stored in free-form directory structure.

Written in Python, it is built on the tornado framework, an asynchronous non-blocking web library tuned for high performance and scalability.

The core application in /server.py implements the tornado.web.Application class, with threaded asynchronous handlers for each endpoint. It is meant to be deployed with supervisord process control system, in multiple instances listening to different ports, behind a nginx proxy. The main process is run on the default 8080 port.

On first run the server builds a sqlite3 cache of EPUB files stored in the EPUB_FILES_PATH directory (set in data.py) in order to avoid filesystem traversal on each request. The cache is then updated with a periodic callback invoked with a default interval of 120s, or an interval provided by CLI argument.

Exhaustive documentation for the implemented HTTP request may be found on the official DOCS. At the present stage the API is designed to interact with AJAX calls and does not implement any kind of UI. This may change, tho.

Licence

The source code is provided as-is under the MIT Licence. TL;DR? Do whatever you wish with it, but keep the original attribution.

Contribute

Suggestions, pull requests, issues and NOS feedback are welcome. The present code shows a few weakness, in particular the database access abstraction (or the lack of one) and could be extended in many ways, for example user authentication, alternative HTML output (care of tornado templating system?) for JSON responses when the request comes from a browser. Also, the EPUB class might be extended to comply with richer EPUB3 metadata.

About

A prototype implementation of a set of public RESTful APIs meant to enable clients to retrieve metadata and contents from a bunch of digital publications in EPUB2 format.

License:MIT License