Question about File() and Resource()
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?
anyone? Please, I'm trying very hard to get this working!
On Sat, Nov 21, 2009 at 3:19 PM, Someone Something
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?
ssteinerX@gmail.com wrote:
On Nov 21, 2009, at 7:23 PM, Someone Something wrote:
anyone? Please, I'm trying very hard to get this working!
Try googling "twisted serve static file" also, look here:
Twisted Documentation: Using the Twisted Application Framework
S
Als, JP's been writing a really great tutorial series on his blog, and that will likely help you out tremendously: http://jcalderone.livejournal.com/tag/sixty%20seconds Have fun! d
That's exactly what i'm following. On Sat, Nov 21, 2009 at 7:30 PM, Duncan M. McGreggor < duncan.mcgreggor@gmail.com> wrote:
ssteinerX@gmail.com wrote:
On Nov 21, 2009, at 7:23 PM, Someone Something wrote:
anyone? Please, I'm trying very hard to get this working!
Try googling "twisted serve static file" also, look here:
Twisted Documentation: Using the Twisted Application Framework
S
Als, JP's been writing a really great tutorial series on his blog, and that will likely help you out tremendously:
http://jcalderone.livejournal.com/tag/sixty%20seconds
Have fun!
d
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
On Nov 22, 2009, at 12:07 PM, Someone Something wrote:
That's exactly what i'm following.
The instructions don't say that you have to: twistd -ny whatever.py at the end. Is that the missing link? S
On Sat, Nov 21, 2009 at 7:30 PM, Duncan M. McGreggor
wrote: ssteinerX@gmail.com wrote: On Nov 21, 2009, at 7:23 PM, Someone Something wrote:
anyone? Please, I'm trying very hard to get this working!
Try googling "twisted serve static file" also, look here:
Twisted Documentation: Using the Twisted Application Framework
S
Als, JP's been writing a really great tutorial series on his blog, and that will likely help you out tremendously:
http://jcalderone.livejournal.com/tag/sixty%20seconds
Have fun!
d
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
On Sat, 21 Nov 2009 16:19 -0500, "Someone Something"
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.
participants (4)
-
Duncan M. McGreggor
-
Peter Westlake
-
Someone Something
-
ssteinerX@gmail.com