Skip to content

Instantly share code, notes, and snippets.

@navneetsaluja
Created June 24, 2020 12:35
Show Gist options
  • Save navneetsaluja/d8e5b845baecbf3bca7d029a87d81b67 to your computer and use it in GitHub Desktop.
Save navneetsaluja/d8e5b845baecbf3bca7d029a87d81b67 to your computer and use it in GitHub Desktop.
const hostname = process.env.HOST;
const port = process.env.PORT;
app.use((req, res, next) => {
console.log(req.headers);
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html');
res.end('<html><body><h1>This is an Express Server</h1></body></html>');
});
const server = http.createServer(app);
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment