Skip to content

Instantly share code, notes, and snippets.

@robianmcd
Created January 24, 2017 02:19
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 robianmcd/41f08c41461b4e637e2a0d914b13fa40 to your computer and use it in GitHub Desktop.
Save robianmcd/41f08c41461b4e637e2a0d914b13fa40 to your computer and use it in GitHub Desktop.
static express server
let express = require('express');
let app = express();
let path = require('path');
app.use(express.static(path.join(__dirname, '.')));
app.all('/*', function (req, res) {
res.sendFile('index.html', {root: __dirname});
});
let server = app.listen(process.env.PORT || 3333, function () {
let host = server.address().address;
let port = server.address().port;
console.log('Listening at http://%s:%s', host, port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment