Version 3 (modified by Itamar Turner-Trauring, 6 years ago) (diff)

Web section

The Twisted Book

What is Twisted?

Twisted is an event-driven networking engine written in Python and licensed under the MIT license.

Easily Implement Custom Servers and Clients

Twisted makes it easy to implement servers. 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):

class EchoFactory(protocol.Factory):
    def buildProtocol(self, addr):
        return Echo()

reactor.listenTCP(1234, EchoFactory())

Learn more about writing servers, writing clients and the core networking libraries (SSL, scheduled events, unit testing, and more).

Scalable Web Applications

Twisted includes scalable, event-driven HTTP support. Here's a sample web application:

from twisted.web import server, resource
from twisted.internet import reactor

class HelloResource(resource.Resource):
    def render_GET(self, request):
        request.setHeader("content-type", "text/plain")
        return "Hello, world!"

reactor.listenTCP(8080, server.Site(HelloResource()))

Learn more about web application development and Twisted's HTTP client.

And More!


General Information:

More Useful Pointers:

Twisted Sponsors

Become a 2011 Sponsor Today!

Donations are tax-deductible.

Your Logo Here

You can use the form above for both personal donations and corporate sponsorships; for any donation above the Bronze level, we will display your logo here on the front page.