For systems with the command line tool dict installed, rest4dict adds a REST API service.
- dict available on the path
- Python
rest4dict is built on top of flask in python.
export FLASK_APP=rest4dict.py
flask run
By default it runs on the localhost on port 5000. Port and host can be set with
flask run --host=0.0.0.0 --port=8123
The endpoint is /api/dict Input fields are source, target, and word. Source and target are two-letter language codes (en,es,it, etc.) and word is the word to be translated. On successful return, the xlation contains the definition of the word.
A test.py script is provided which shows some examples.
GNU GENERAL PUBLIC LICENSE
- Handle the cases where the lookup fails better. Catch the "did you mean" output and return it.
Please submit pull requests! Before doing so, make sure the test.py passes, and run pylint until it shows 10/10