Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 7b973fb3c8298f606d9b435aff551ab6 > files > 3221

python2-twisted-19.2.1-1.1.mga7.armv7hl.rpm

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
This example demonstrates a very simple HTTP proxy.

Usage:
    $ python proxy.py

Then configure your web browser to use localhost:8080 as a proxy, and visit a
URL (This is not a SOCKS proxy). When browsing in this configuration, this
example will proxy connections from the browser to the server indicated by URLs
which are visited.

See also logging-proxy.py for a proxy with additional features.
"""

from twisted.web import proxy, http
from twisted.internet import reactor

class ProxyFactory(http.HTTPFactory):
    def buildProtocol(self, addr):
        return proxy.Proxy()

reactor.listenTCP(8080, ProxyFactory())
reactor.run()