Skip to content

Instantly share code, notes, and snippets.



Created Nov 9, 2019
What would you like to do?
// 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!');
// Make sure to terminate other requests too, so they don't hang indefinedly.
// Actually start the server
console.log('Running on port: ' + port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.