Skip to content

Instantly share code, notes, and snippets.

@ldco2016
Created December 21, 2018 04:17
Show Gist options
  • Save ldco2016/9aa18e67c37c3a55bd683cbdf31d0009 to your computer and use it in GitHub Desktop.
Save ldco2016/9aa18e67c37c3a55bd683cbdf31d0009 to your computer and use it in GitHub Desktop.
Node app server for Docker container with Redis
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