Re: Question about File() and Resource()
"Peter Westlake" <[email protected]>
| Newsgroups | gmane.comp.python.twisted.web |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 21 Nov 2009 16:19 -0500, "Someone Something" <[email protected]> wrote: > I'm trying to make a homepage that has a link to a page that was made with > file. The only thing that currently works is the File() page. I have > absolutely no idea how to do the rest (no, its not homework). Here's my > current code: > from twisted.web.server import Site > from twisted.web.resource import Resource > from twisted.internet import reactor > from twisted.web.static import File > > > root=Resource() > root.putChild("programming", File("/home/dhaivat/")); > > factory= Site(root) > reactor.listenTCP(8080, factory); > reactor.run(); > > How can I implement the home page? Your root is a Resource that doesn't have any content in it. Try putting the File resource at the top level: root = File("/home/dhaivat/") I tried this first with File("/tmp/index.html"), which didn't work. Giving it the directory instead of the file did work, and it even recognized index.html. Peter.