title: create simple python server to provide json for d3
body: <p>I use <code>d3.json()</code> to get json data for d3. And I tend to start a python server to provide that data. I find a snippet on the web: </p>
  
  <pre><code>class MyTCPServer(SocketServer.ThreadingTCPServer):
      allow_reuse_address = True
  
  class MyTCPServerHandler(SocketServer.BaseRequestHandler):
      def handle(self):
          try:
              data = getJson() # json data is stored here
              self.request.sendall(json.dumps(data))
          except Exception, e:
              pass
  </code></pre>
  
  <p>When I request it via browser, I can see the result. However, d3 always returns null</p>
  
  <pre><code>d3.json('http://localhost', function(json) {
      alert(json)
  });
  </code></pre>
  
  <p>What should I do to get the right result?</p>