Skip to content

chrswt/vicarious-microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vicarious Pig Latin Microservice

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:

  • Listens on port 80, accepts a string that contains at least one word, but potentially entire paragraphs.
  • Convert the words to Pig Latin and return the results in the HTTP message body.
  • Preserve all of the punctuation in the original string.

Dependencies

Try the Deployed Version

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

Setup

Install all dependencies

Install virtualenv using pip if you do not already have it installed, pip install virtualenv.

  • Troubleshooting: If you have Anaconda installed, it is likely that your 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.

Launching the server

To run the server, use the command sudo make launch

  • Troubleshooting: because we are running on a protected port, 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.

Running tests

To run the included unit tests, use the command make test (note that this must be run after the server has been launched).

Shutdown and cleanup

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.

Using the API

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.

Resources

About

Vicarious Pig Latin Microservice 🐷

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published