Search a recipe collection with a query parser and evaluation engine allowing arbitrary boolean queries
Create a virtual environment and use the package manager pip to install the dependencies.
# Create the virtual environment
python3 -m venv venv
# Activate the virtual environment
.\venv\Scripts\activate.bat # on Windows
. venv/bin/activate # on macOS/Linux
# Install the dependencies
pip3 install -r requirements.txtPopulate some test data:
$ python database.pyTo search from the command line:
$ python main.pyTo run the API server:
$ python server.pyFrom another terminal, make a request:
$ curl -G "http://localhost:5000/api/v1/search" \
--data-urlencode "q=(butter and (egg or taro)) and not (caramel or salt)"
{
"results":[
{
"title":"french toast",
"body":"toast butter milk egg"
},
{
"title":"pancakes",
"body":"butter flour water sugar baking-soda egg"
}
]
}