Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created October 23, 2017 15:54
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 xeoncross/39d827295c2eaa09c5de9687c03e905f to your computer and use it in GitHub Desktop.
Save xeoncross/39d827295c2eaa09c5de9687c03e905f to your computer and use it in GitHub Desktop.
Simple long-running node process
const express = require('express');
const app = express();
let isOn = true
// Testing
app.get('/off', (req, res) => {
isOn = false
res.json({ method: req.method, path: req.path, on: isOn });
});
app.get('/on', (req, res) => {
isOn = true
res.json({ method: req.method, path: req.path, on: isOn });
});
// Report what the current status is
setInterval(() {
console.log(isOn);
}, 1000);
// The "catchall" handler: for any request that doesn't
// match one above, send back React's index.html file.
// app.get('*', (req, res) => {
// res.sendFile(path.join(__dirname+'/client/build/index.html'));
// });
app.listen(3000, (err) => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment