1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Twisted/DictionaryApp.py Fri Sep 09 17:33:19 2005 +0000
1.3 @@ -0,0 +1,32 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Adapters.Twisted import deploy
1.7 +import Dictionary
1.8 +from Dictionary.Dict import Dict
1.9 +
1.10 +# Initialise a dictionary.
1.11 +
1.12 +import sys
1.13 +if len(sys.argv) < 2:
1.14 + print "Please specify a file to be indexed."
1.15 + sys.exit(1)
1.16 +
1.17 +filename = sys.argv[1]
1.18 +
1.19 +if len(sys.argv) > 2:
1.20 + encoding = sys.argv[2]
1.21 +else:
1.22 + encoding = None
1.23 +
1.24 +dict = Dict(filename, encoding)
1.25 +
1.26 +# Get a simple Web site.
1.27 +
1.28 +resource = Dictionary.get_site(dict)
1.29 +
1.30 +# Special magic incantation.
1.31 +
1.32 +print "Serving..."
1.33 +deploy(resource, handle_errors=0)
1.34 +
1.35 +# vim: tabstop=4 expandtab shiftwidth=4