|Version 208 (modified by oubiwann, 4 years ago) (diff)|
What is Twisted?
Twisted is an event-driven networking engine written in Python and licensed under the open source MIT license.
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 numberRequests = 0 def render_GET(self, request): self.numberRequests += 1 request.setHeader("content-type", "text/plain") return "I am request #" + str(self.numberRequests) + "\n" reactor.listenTCP(8080, server.Site(HelloResource())) reactor.run()
And Other Protocols
- Downloads - Get it!
- Documentation - Everything you need to know to get started
- List Info - Access the twisted-python and twisted-web mailing lists
- News - Read the latest news about Twisted
- Tracker - Report a bug or request a feature (Registration is required)
More Useful Pointers:
- The Twisted Community - Get in touch with other Twisted users and developers
- Contributing to Twisted
- Our Development Process
- Success Stories - Read about people who have been successful with Twisted
- The Twisted Show - Interviews and podcasts with businesses and projects that use Twisted
- Software that uses Twisted - Learn what other projects are using Twisted
- The Labs - What is Twisted Matrix Laboratories?
- Sponsors - Individuals and organisations aid development with donations of hardware, software, hosting, and so on
- Windows - We're especially seeking resources to help improve Twisted on Windows