Rewrite of main.py to use a REST API.