[Twisted-Python] serving up a directory

Clark C. Evans cce at clarkevans.com
Sun Feb 23 00:49:00 EST 2003

On Sun, Feb 23, 2003 at 12:08:33AM -0500, Jp Calderone wrote:
|     app = Application("whatever")
|     ...
|     app.listenTCP(port, siteInstance)
|     app.listenTCP(anotherPot, smtpServerFactory)
|     ...
|     app.run(save=0)

Thanks Jp


I think I found an unexpected behavior in putChild and 
the Redirect resource, here is my code snippet...

class Redirect(static.Redirect):
    def __init__(self, url):
        self.url = url

def run():
    root = Resource()
    site = server.Site(root)

Anyway, first, I found the "Redirect" resource not to 
behave as expected... for some reason it wanted a request?!
for the argument of __init__ instead of a url. 

But second, and most importantly, I wanted to have my
static content served from the root (without the redirect); 
I initally tried:


But unfortunately, this introduced two slashes after
the server, ie,  http://server//index.html which 
causes problems down the line.  Above was my current
work-aroud (using a redirect to a sub-folder).  However,
ideally, I'd like the above putChild to work as expected
and not to introduce the double slashes.   

I looked into the Rewrite resource for a while, but I 
couldn't find any examples and it wasn't obvious how
to use it (it's also getting late)

Regardless, this toolset is splendid; that I've gotten
this far (ported a rather complicated mod_python program
in less than 8 hours) is quite impressive indeed.  Now
the last bit... getting the database pooling to work!

Thank you so much,

;) Clark

More information about the Twisted-Python mailing list