JSONP Proxy Server

10 March 2009

I was doing some JSON mashing the other day and wanted to use data from different web pages. XmlHttpRequest was not an option, because I wanted to fetch content from different domains.

As many web pages don't provide an interface that returns JSONP, I wrote a very simple proxy server in python that does just that. More specifically, the proxy forwards the incoming request to a hard coded url and returns the result wrapped into a callback function which is provided by the user.
Once the proxy is running, you can hit it with JSONP requests:Or, if you prefer doing it in JQuery, which allows you to then handle the callback in a closure: