It's now time to run the Tree API service program and send it RESTful API requests to make it work. Here are the steps to run and test our Tree API service:
- Change into the chapter14/tree_api_service folder and start the main.py script, as shown:
# Terminal 1
(venv) $ cd tree_api_service
(venv) $ python main.py
* Serving Flask app "main" (lazy loading)
... truncated ...
INFO:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
- Next, open a second terminal and run the following curl command to set the repeating light pattern sequence to red, blue, black:
# Terminal 2
$ curl -X POST "http://localhost:5000/lights/color?colors=red,blue,black&pattern=yes"
- Also in Terminal 2, run this next command to start making the lights animate:
# Terminal 2
$ curl -X POST "http://localhost:5000/lights/animation?mode=left&speed=5"
Other animation modes you can use for the mode parameter, in addition to left, include...