diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-09-08 16:02:31 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-09-08 17:03:34 +0200 |
commit | ebd539b49f0706918e979dc921cf454ae448eaf9 (patch) | |
tree | 1c541027c735e18c7486d5d9ebda7367278ac244 /examples/proxapp | |
parent | d06b4bfa4e4cc51e903b49e246d7771726a3e3a4 (diff) | |
download | mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.tar.gz mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.tar.bz2 mitmproxy-ebd539b49f0706918e979dc921cf454ae448eaf9.zip |
update examples, fix #353
Diffstat (limited to 'examples/proxapp')
-rwxr-xr-x | examples/proxapp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/examples/proxapp b/examples/proxapp deleted file mode 100755 index 9f299d25..00000000 --- a/examples/proxapp +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -""" -This example shows how to graft a WSGI app onto mitmproxy. In this -instance, we're using the Bottle framework (http://bottlepy.org/) to expose -a single simplest-possible page. -""" -import bottle -import os -from libmproxy import proxy, flow - -@bottle.route('/') -def index(): - return 'Hi!' - - -class MyMaster(flow.FlowMaster): - def run(self): - try: - flow.FlowMaster.run(self) - except KeyboardInterrupt: - self.shutdown() - - def handle_request(self, f): - f = flow.FlowMaster.handle_request(self, f) - if f: - f.reply() - return f - - def handle_response(self, f): - f = flow.FlowMaster.handle_response(self, f) - if f: - f.reply() - print f - return f - - -config = proxy.ProxyConfig( - cacert = os.path.expanduser("~/.mitmproxy/mitmproxy-ca.pem") -) -state = flow.State() -server = proxy.ProxyServer(config, 8080) -# Register the app using the magic domain "proxapp" on port 80. Requests to -# this domain and port combination will now be routed to the WSGI app instance. -server.apps.add(bottle.app(), "proxapp", 80) -m = MyMaster(server, state) -m.run() - |