CGI to run query and produce json