Skip to content

Instantly share code, notes, and snippets.

@rikwatson
Created April 1, 2019 12:48
Show Gist options
  • Save rikwatson/abd4bbbe6a6567069aa1e1a5b364ce49 to your computer and use it in GitHub Desktop.
Save rikwatson/abd4bbbe6a6567069aa1e1a5b364ce49 to your computer and use it in GitHub Desktop.
HTTP Proxy in Python
"""
From: http://wiki.python.org/moin/Twisted-Examples
Via: http://stackoverflow.com/questions/4412581
"""
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment