[Twisted-Python] More problems running examples

Joe Halliwell joeh at dai.ed.ac.uk
Fri Feb 20 07:41:12 EST 2004


The code is fine, so I wonder what URL you're pointing the browser at.
Tried http://127.0.0.1:8011/ ? Anything else will produce a resource
error since res has no child resources.

Cheers,
Joe

> #####################################################################
> # teg2.py
> 
> from twisted.web import server, resource
> from twisted.internet import reactor
> from twisted.web.resource import Resource
> 
> class Hello(resource.Resource):
> 
>    def getChild(self, name, request):
>       if name == '':
>          result = self
>       else:   
>          result = Resource.getChild(self, name, request)
>       print "in Hello:getChild, result=%r" % (result,)
>       return result
> 
>    def render(self, request):
>       s = """<html>
>       Hello, world! I am located at %r.
>       </html>""" % (request.prepath) 
>       return s
> 
> print "===== Running teg2.py (simple webserver) ====="
> res = Hello()
> 
> site = server.Site(res)
> reactor.listenTCP(8011, site)
> reactor.run()
> #####################################################################
> 
> 
> Now, this does actually run, however whenever I point my webserver at it,
> all that comes back is a 404 error with the text:
> 
>    No Such Resource
>    No such child resource.
> 
> And my program writes to stdout:
> 
>    in Hello:getChild, result=<twisted.web.error.NoResource instance at
>    0x406adb0c>
> 
> -- 
> Phil Hunt, phil.hunt at tech.mrc.ac.uk
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20040220/c3e1a5b4/attachment.pgp 


More information about the Twisted-Python mailing list