The task was to implement a simple search API which accepts a word list and enables the searching of words in that list that start with a specified string.
The program you write is a small HTTP server which exposes the following two endpoints:
The dictionary of words to search through.
Input: JSON containing an array of words, e.g. ["foo", "bar", ...]
Output: Return an HTTP 200 status for valid data.
All words that start with :string
- e.g. /search/foo
should return all
words in the supplied dictionary starting with foo
, including foo
itself.
Input: the string, specified in the URL.
Output: A JSON array of words in the dictionary which start with the specified string, all in lower case. Should return an HTTP 200 status for valid data, even if no words are found (just return an empty JSON array in this case).