Last active
February 12, 2016 13:13
-
-
Save vamsee/6243e3e1197eb25aa95a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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