Created
January 24, 2017 02:19
-
-
Save robianmcd/41f08c41461b4e637e2a0d914b13fa40 to your computer and use it in GitHub Desktop.
static express server
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
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