[Twisted-Python] Serving different resource types from the same directory
Remi Cool
mailinglists at smartology.nl
Mon Nov 28 02:14:48 MST 2005
Olivier Laurent wrote:
>I'm trying to serve 2 different kind of resources from the same
>directory. I can, with no problem, serve one kind or the other but not
>the two resource types at the same time.
>
>Examples abounds on the web on how to serve one kind of resources from
>subdirectory /foo and another kind from subdirectory /bar. But no
>example on how to serve different kind of resources from the same
>directory.
>
>Here is how I tried:
>
># [...]
>
>PATH = '/var/www/'
>
>pt_resource = static.File(PATH)
>pt_resource.processors = { '.pt' : PTResource }
>pt_resource.indexNames = [ 'index' + '.pt' ]
>
>rst_resource = static.File( PATH )
>rst_resource.processors = { '.rst' : RSTResource }
>rst_resource.indexNames = [ 'index' + '.rst' ]
>
>#root = Resource() # I tried this too
>root = static.File(PATH)
>
>root.putChild(PATH, pt_resource)
>root.putChild(PATH, rst_resource)
>
>reactor.listenTCP(
> 80,
> server.Site( root )
> )
>reactor.run( )
># this is the end
>
Try this:
myRs = static.File(PATH)
myRs.processors = {'.pt' : PTResource, '.rst' : RSTResource}
myRs.indexNames = ['index' + '.pt', 'index' + '.rst' ]
- Remi -
More information about the Twisted-Python
mailing list