Skip to content

Instantly share code, notes, and snippets.

@vamsee
Last active February 12, 2016 13:13
Show Gist options
  • Save vamsee/6243e3e1197eb25aa95a to your computer and use it in GitHub Desktop.
Save vamsee/6243e3e1197eb25aa95a to your computer and use it in GitHub Desktop.
var express = require('express'),
http = require('http'),
redis = require('redis');
var app = express();
var client = redis.createClient('6379', 'localhost');
app.get('/', function(req, res, next) {
client.incr('counter', function(err, counter) {
if(err) return next(err);
res.send('This page has been viewed ' + counter + ' times!');
});
});
http.createServer(app).listen(process.env.PORT || 8080, function() {
console.log('Listening on port ' + (process.env.PORT || 8080));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment