|Version 190 (modified by itamar, 4 years ago) (diff)|
Twisted 11.0.0 tar
Twisted 11.0.0 for Python 2.5
Twisted 11.0.0 for Python 2.6
Twisted 11.0.0 for Python 2.7
The Twisted Book
What is Twisted?
Twisted is an event-driven networking engine written in Python and licensed under the open source MIT license.
Nov 4, 2011: Twisted 11.1 rc2 has been released.
Easy Custom Servers and Clients
Twisted makes it easy to implement custom network applications, both servers and clients. Here's a TCP server that echoes back everything that's written to it:
from twisted.internet import protocol, reactor class Echo(protocol.Protocol): def dataReceived(self, data): self.transport.write(data) class EchoFactory(protocol.Factory): def buildProtocol(self, addr): return Echo() reactor.listenTCP(1234, EchoFactory()) reactor.run()
Event-Driven Web Applications
Twisted includes an event-driven web server. Here's a sample web application:
from twisted.web import server, resource from twisted.internet import reactor class HelloResource(resource.Resource): isLeaf = True def render_GET(self, request): request.setHeader("content-type", "text/plain") return "Hello, world!" reactor.listenTCP(8080, server.Site(HelloResource())) reactor.run()
And Other Protocols
More Useful Pointers: