XSLTools

examples/BaseHTTPRequestHandler/DictionaryApp.py

687:ae7bdbf61e32
2009-06-22 Paul Boddie Added some error handling to the questionnaire application.
     1 #!/usr/bin/env python     2      3 from WebStack.Adapters.BaseHTTPRequestHandler import deploy     4 import Dictionary     5 from Dictionary.Dict import Dict     6      7 # Initialise a dictionary.     8      9 import sys    10 if len(sys.argv) < 2:    11     print "Please specify a file to be indexed."    12     sys.exit(1)    13     14 filename = sys.argv[1]    15     16 if len(sys.argv) > 2:    17     encoding = sys.argv[2]    18 else:    19     encoding = None    20     21 dict = Dict(filename, encoding)    22     23 # Get a simple Web site.    24     25 resource = Dictionary.get_site(dict)    26     27 # Special magic incantation.    28     29 print "Serving..."    30 deploy(resource, handle_errors=0)    31     32 # vim: tabstop=4 expandtab shiftwidth=4