Twisted

From air
Revision as of 09:26, 5 April 2013 by Donsez (talk | contribs) (Created page with "''Twisted is an event-driven networking engine written in Python (MIT license)'' Protocols : HTTP (WS ?, REST ?), SMTP, POP3, IMAP, SSHv2, DNS, ... ==Docs== * http://twistedmat…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Twisted is an event-driven networking engine written in Python (MIT license)

Protocols : HTTP (WS ?, REST ?), SMTP, POP3, IMAP, SSHv2, DNS, ...

Docs

Examples

Web Server

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()