-
Flask + Python application created with reference from http://oldblog.antirez.com/post/autocomplete-with-redis.html. The
/wordsAPI will add new words to the Redis datastore and/autocompleteAPI will suggest probable words to complete the query. -
Dockerfileusespython:3.8-alpine. Application is hosted onlocalhost:5000. Redis is running on container port6379. -
docker-composewill spin up two separate containers - oneapi_web_1andapi_redis_1.
-
Unzip the Tar Ball.
tar -zxvf redis-auto-complete.tar.gz -
Change Directory to api directory.
cd redis-auto-complete/api/ -
Run docker-compose to start the flask application.
docker-compose up -d -
Use cURL client or Browser to perform the following GET request to add words to the Redis keystore.
curl GET 'http://localhost:5000/add_word?word=box8'Sample Output:
Added -
Use cURL client or Browser to to perform the following GET request to query auto-completion suggestions from the Redis keystore.
curl GET 'http://localhost:5000/autocomplete?query=bo'Sample Output:
[ "box8" ] -
To shut the application enter the following command:
docker-compose down
Case insensitive auto-completion.