Friday, August 6, 2010

极速 Twisted Web 60秒(3): 静态URL处理

[cc lang="python"]
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("foo", File("/tmp"))
root.putChild("bar", File("/lost+found"))
root.putChild("baz", File("/opt"))

factory = Site(root)
reactor.listenTCP(8880, factory)
reactor.run()
[/cc]

No comments:

Post a Comment