Skip to content

Instantly share code, notes, and snippets.

@robertklep
Created May 10, 2013 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertklep/5552998 to your computer and use it in GitHub Desktop.
Save robertklep/5552998 to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
app.use(express.static(__dirname));
app.get('/data.json', function(req, res) {
res.set('Cache-Control', 'public, max-age=20');
res.send({ value : Math.random() });
});
app.listen(3012);
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
setInterval(function() {
$.getJSON('/data.json', function(r) {
console.log('R', r.value);
});
}, 1000);
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment