REST requests are handled via the web server's CGI gateway by means of a script, /path/to/repo/www/chapter_06/rest.py. Because this is a web script, we need the opening tag that identifies the location of the Python executable to the web server's CGI process. The script also needs to have its permissions set so that it is executable. After the opening tag is the expected series of import statements:
#!/usr/bin/python
import os,sys
src_path = os.path.realpath('../../chapters/06/src')
sys.path.append(src_path)
import cgi
from collections import Counter
from config.config import Config
from web.responder.rest import RestResponder
from db.mongodb.connection import Connection
from sweetscomplete.domain.product import ProductService
from sweetscomplete.entity.product import Product
Next, as with the other action scripts described in this chapter and the previous one, we use the Config class to create a database connection and define a ProductService...