Created
December 21, 2018 04:17
-
-
Save ldco2016/9aa18e67c37c3a55bd683cbdf31d0009 to your computer and use it in GitHub Desktop.
Node app server for Docker container with Redis
This file contains hidden or 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
const express = require('express'); | |
const redis = require('redis'); | |
client.set('visits', 0); | |
const app = express(); | |
const client = redis.createClient(); | |
app.get('/', (req, res) => { | |
client.get('visits', (err, visits) => { | |
res.send('Number of visits is' + visits); | |
client.set('visits', parseInt(visits) + 1); | |
}); | |
}); | |
app.listen(8081, () => { | |
console.log('Listening on port 8081'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment