Add support to index.py to run as CGI or CLI.