Twisted
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
- http://twistedmatrix.com/trac/
- Livre : Twisted Network Programming Essentials, 2nd Edition : Event-driven Network Programming with Pytho By Jessica McKellar, Abe Fettig, 2013, http://shop.oreilly.com/product/0636920025016.do
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()