jQuery, AJAX and Google App Engine

Heres a quick example of how to use ajax with Google App Engine. First the code in index.html...

<html><head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script></head><body> <script type="text/javascript"> $(document).ready(function() {  $.post("/mvc/", {name:"Ross"}, function(data){   $("#test").html(data);  }); }); </script> <div id="test">loading...</div></body></html>

And here's the main.py. The get method returns the initial page and the post method handles the ajax callback...

#!/usr/bin/env pythonimport osimport wsgiref.handlersfrom google.appengine.ext import webappfrom google.appengine.ext.webapp import template# MvcHandlerclass MvcHandler(webapp.RequestHandler):def get(self): path = os.path.join(os.path.dirname(__file__), 'templates/index.html') self.response.out.write(template.render(path, {}))def post(self): self.response.out.write("Hello "+self.request.get('name'))# maindef main(): application = webapp.WSGIApplication([('/mvc/', MvcHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)if __name__ == '__main__': main()