title: Why does PHP just work with Ajax but Python doesn't?
body: <p>Building a PHP script that responds to an Ajax request is as easy as:</p>
  
  <pre><code>&lt;?php
    $command = $_POST["command"];
    if ($command == "say_hello") {
      $name = $_POST["name"];
      echo json_encode(array("message" =&gt; "Hello, " . $name));
    }
  ?&gt;
  </code></pre>
  
  <p>and, at least if you're using jQuery on the client side, and if you specified a callback function on the original request, the array containing the message will be passed into that callback function.</p>
  
  <p>But with Python it's not that simple. Or at least I haven't figured out how to make it that simple.  If I just try to "print" a response (paralleling PHP's "echo" statement above) the client doesn't get anything back.</p>
  
  <p>Whenever I've looked on the internet for how to respond to an Ajax request with Python, the answer always involves using Django or some other web framework.</p>
  
  <p>And I know those things are great, but what is PHP doing that makes using a similar package unnecessary?  I would like to be writing my server-side script in Python instead of PHP, but I'd prefer a D.I.Y. approach to using a third-party framework for what should be (right?) a pretty simple task.</p>
  
  <p>Any help?  An example of how to do this would be much appreciated.</p>