This is related to the difference between a URL ending with a slash and one without. It appears that Twisted considers a URL at the top level (like your http://localhost:8000
) to include an implicit trailing slash (http://localhost:8000/
). That means that the URL path includes an empty segment. Twisted then looks in the resource
for a child named ''
(empty string). To make it work, add that name as a child:
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.static import File
resource = File('/home/venky/python/twistedPython/index.html')
resource.putChild('', resource)
factory = Site(resource)
reactor.listenTCP(8000, factory)
reactor.run()
Also, your question has port 8080
but your code has 8000
.