title: How do I get my simple twisted proxy to work?
body: <p>I am attempting to make use of the <a href="http://twistedmatrix.com/trac/wiki/TwistedWeb" rel="nofollow noreferrer">Twisted.Web</a> framework.</p>
  
  <p>Notice the three line comments (#line1, #line2, #line3). I want to create a proxy (gateway?) that will forward a request to one of two servers depending on the url. If I uncomment either comment 1 or 2 (and comment the rest), the request is proxied to the correct server. However, of course, it does not pick the server based on the URL.</p>
  
  <pre><code>from twisted.internet import reactor
  from twisted.web import proxy, server
  from twisted.web.resource import Resource
  
  class Simple(Resource):
      isLeaf = True
      allowedMethods = ("GET","POST")
  
      def getChild(self, name, request):
          if name == "/" or name == "":
              return proxy.ReverseProxyResource('localhost', 8086, '')
          else:
              return proxy.ReverseProxyResource('localhost', 8085, '')
  
  simple = Simple()
  # site = server.Site(proxy.ReverseProxyResource('localhost', 8085, '')) #line1   
  # site = server.Site(proxy.ReverseProxyResource('localhost', 8085, '')) #line2   
  site = server.Site(simple)                                              #line3   
  reactor.listenTCP(8080, site)
  reactor.run()
  </code></pre>
  
  <p>As the code above currently stands, when I run this script and navigate to server "localhost:8080/ANYTHING_AT_ALL" I get the following response.</p>
  
  <blockquote>
    <p>Method Not Allowed</p>
    
    <p>Your browser approached me (at /ANYTHING_AT_ALL) with the method "GET". I
    only allow the methods GET, POST here.</p>
  </blockquote>
  
  <p>I don't know what I am doing wrong? Any help would be appreciated.</p>