from twisted.application.service import Application from twisted.application import strports from twisted.web import server, resource class MyResource(resource.Resource): def getChild(self, name, request): # If this resource is located at /foo, and the user requests /foo/bar, # it is up to getChild('bar') to figure out what resource to display. # This tells the web server that no matter what child we might need, # we want this resource to always return itself. return self def render(self, request): result = '''
Hello, world!
request.path = %s
''' % request.path return result # create the all-encompassing application object application = Application('rosetta1') # create our web site site = server.Site(resource=MyResource()) # create a service containing our web site and listening on TCP port 1450 svc = strports.service('tcp:1450', site) svc.setServiceParent(application)