Created
November 9, 2019 17:40
-
-
Save Waltari10/5dbfd3c87064df5a5fdbbc15e2cc1db8 to your computer and use it in GitHub Desktop.
This file contains 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
// Comes with Node | |
const http = require('http'); | |
// Access dynamic Heroku port with process.env.PORT. 3001 is a fallback. | |
const port = process.env.PORT || 3001; | |
// Create a server | |
const server = http.createServer((req, res) => { | |
// If call was made to /hello-world pathname. We aren't using REST here! | |
if (req.url === '/hello-world') { | |
res.end('hello world!'); | |
return; | |
} | |
// Make sure to terminate other requests too, so they don't hang indefinedly. | |
res.end(''); | |
}); | |
// Actually start the server | |
server.listen(port); | |
console.log('Running on port: ' + port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment