Switching index.py over to api