Updated example to work on the server as well as in browser.