Skip to content

Instantly share code, notes, and snippets.

@zhangcheng
Last active December 17, 2015 11:59
Show Gist options
  • Save zhangcheng/5606578 to your computer and use it in GitHub Desktop.
Save zhangcheng/5606578 to your computer and use it in GitHub Desktop.

Revisions

  1. @zhangcheng-aa zhangcheng-aa renamed this gist May 19, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @zhangcheng-aa zhangcheng-aa created this gist May 19, 2013.
    21 changes: 21 additions & 0 deletions wsgi_intercept
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import wsgi_intercept
    import wsgi_intercept.mechanize_intercept
    from wsgi_intercept.test_wsgi_app import create_fn
    wsgi_intercept.add_wsgi_intercept('some_host', 80, create_fn)
    b = wsgi_intercept.mechanize_intercept.Browser()
    response = b.open('http://some_host:80')
    response.read()


    import wsgi_intercept
    import wsgi_intercept.mechanize_intercept
    from django.core.handlers.wsgi import WSGIHandler
    wsgi_intercept.add_wsgi_intercept('localhost', 17681, WSGIHandler)
    b = wsgi_intercept.mechanize_intercept.Browser()
    b.set_handle_robots(False)
    b.open('http://localhost:17681/account/login/')
    b.select_form(nr=1)
    b.form['username'] = '[email protected]'
    b.form['password'] = 'admin'
    response = b.submit()
    response.read()