[Twisted-web] Question about File() and Resource()
Peter Westlake
peter.westlake at pobox.com
Mon Nov 23 11:56:33 EST 2009
On Sat, 21 Nov 2009 16:19 -0500, "Someone Something"
<fordhaivat at gmail.com> 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.
More information about the Twisted-web
mailing list