def server(host, port, func):
 def handler(conn):
  try:
   (yield func(conn))
  finally:
   conn.close()
 listener = Listener(host, port)
 try:
  while True:
   conn = (yield listener.accept())
   (yield spawn(handler(conn)))
 except KeyboardInterrupt:
  pass
 finally:
  listener.close()

def server ( host , port , func ) : def handler ( conn ) : try : ( yield func ( conn ) ) finally : conn . close ( ) listener = Listener ( host , port ) try : while True : conn = ( yield listener . accept ( ) ) ( yield spawn ( handler ( conn ) ) ) except KeyboardInterrupt : pass finally : listener . close ( )
require the nginx web server to be installed and running .