Twisted web server not serving files

here I have this little sample snippet, and it just doesn't serve index.html from www dir. what is wrong with the code?

from twisted.internet import reactor from twisted.web import static, server, script import os DIRECTORY = os.getcwd()+"/www" root = static.File(DIRECTORY) root.indexNames = [ 'index.rpy', 'index.html' ] root.processors = { '.rpy': script.ResourceScript } site = server.Site(root) reactor.listenTCP(8090, site) reactor.run() 

all I get is the message "There is no such resource." Is there a way to set up logging or something to figure this out?

+4
source share
2 answers

Record can be customized by adding these lines

 from twisted.python import log import sys log.startLogging(sys.stdout) 
+2
source

When I received this error, I had to add the following:

 def getChild(self, name, request): # for some reason this is needed for the root Resource to render at all if name == b'': return self return super().getChild(name, request) 
0
source

All Articles