def wnb(port=8000, runBrowser=True, logfilename=None):
 global server_mode, logfile
 server_mode = (not runBrowser)
 if logfilename:
  try:
   logfile = open(logfilename, 'a', 1)
  except IOError as e:
   sys.stderr.write("Couldn't open %s for writing: %s", logfilename, e)
   sys.exit(1)
 else:
  logfile = None
 url = ('http://localhost:' + str(port))
 server_ready = None
 browser_thread = None
 if runBrowser:
  server_ready = threading.Event()
  browser_thread = startBrowser(url, server_ready)
 server = HTTPServer(('', port), MyServerHandler)
 if logfile:
  logfile.write(('NLTK Wordnet browser server running serving: %s\n' % url))
 if runBrowser:
  server_ready.set()
 try:
  server.serve_forever()
 except KeyboardInterrupt:
  pass
 if runBrowser:
  browser_thread.join()
 if logfile:
  logfile.close()

def wnb ( port = 8000 , runBrowser = True , logfilename = None ) : global server_mode , logfile server_mode = ( not runBrowser ) if logfilename : try : logfile = open ( logfilename , 'a' , 1 ) except IOError as e : sys . stderr . write ( "Couldn't open %s for writing: %s" , logfilename , e ) sys . exit ( 1 ) else : logfile = None url = ( 'http://localhost:' + str ( port ) ) server_ready = None browser_thread = None if runBrowser : server_ready = threading . Event ( ) browser_thread = startBrowser ( url , server_ready ) server = HTTPServer ( ( '' , port ) , MyServerHandler ) if logfile : logfile . write ( ( 'NLTK Wordnet browser server running serving: %s\n' % url ) ) if runBrowser : server_ready . set ( ) try : server . serve_forever ( ) except KeyboardInterrupt : pass if runBrowser : browser_thread . join ( ) if logfile : logfile . close ( )
run nltk wordnet browser server .