Revision 7 as of 2005-12-07 02:34:09

Clear message

Python Twisted Examples

This page maintained by Jacob ["Mathai"].

http://jacobmathai.blogspot.com

If your OpenSSL ore kerberos header files are not in /usr/include, you may need to supply the -I flag to let the setup script know where to look. The same goes for the libraries of course, use the -L flag. Note that build won't accept these flags, so you have t o run first build_ext and then build! Example:

Simple HTTP Proxy Server (proxy.py)

from twisted.web import proxy, http
from twisted.internet import reactor
from twisted.python import log
import sys
log.startLogging(sys.stdout)
 
class ProxyFactory(http.HTTPFactory):
        protocol = proxy.Proxy
 
reactor.listenTCP(8080, ProxyFactory())
reactor.run()

[jacob@tux]$ python simpleproxy.py
/usr/lib/python2.3/site-packages/twisted/web/proxy.py:22: DeprecationWarning: twisted.protocols.http has moved to twisted.web.http. See http://twistedmatrix.com/projects/web.
  from twisted.protocols import http
2005/12/06 21:47 EST [-] Log opened.
2005/12/06 21:47 EST [-] __main__.ProxyFactory starting on 8001
2005/12/06 21:47 EST [-] Starting factory <__main__.ProxyFactory instance at 0xb73577ac>

Unable to edit the page? See the FrontPage for instructions.