Vicarious Pig Latin Microservice :pig:
This is a microservice built on the Flask Python microframework. This microservice can be used to translate requested strings into Pig Latin, with the following specifications:
A version of this microservice has been deployed on PythonAnywhere and you can test out this microservice in the console using the following command:curl -d "Query anything you want\!" -i -X POST http://chriswt.pythonanywhere.com/api/translate
Install virtualenv
using pip if you do not already have it installed, pip install virtualenv
.
virtualenv
PATH will not work for this particular implementation, this can be fixed by installing virtualenv
with the built-in version of Python like so: /usr/local/bin/pip3.5 install virtualenv
To install all the dependencies required to run this microservice, use the command make install
.
To run the server, use the command sudo make launch
sudo
permissions must be used, either use sudo -s
to activate sudo
permissions for your current Terminal session, or execute the command using sudo make launch
). This launches a virtualenv
with the dependencies installed previously.To run the included unit tests, use the command make test
(note that this must be run after the server has been launched).
To shutdown the microservice, use the command make shutdown
. If you want to clean up all the build files and virtual environment files created, use the command make clean
.
The API can be interacted with at the 127.0.0.1/api/translate
endpoint. For example, we can cURL this resource with the following command:
curl -d "Query string here" -i -X POST 127.0.0.1/api/translate
The API accepts Content-Type: text/plain
or Content-Type: application/x-www-form-urlencoded
(it will also attempt to read from any json
stream) and returns Content-Type: text/plain
.