Skip to content

Instantly share code, notes, and snippets.

@robertcoopercode
Last active November 12, 2017 19:52
Show Gist options
  • Save robertcoopercode/9c3d256b9894fa967fb33ca2f9a35717 to your computer and use it in GitHub Desktop.
Save robertcoopercode/9c3d256b9894fa967fb33ca2f9a35717 to your computer and use it in GitHub Desktop.
// Route that serves index.html
router.get('/', (request, response) => {
response.setHeader('Content-Type', 'text/html');
// Capture the contents of index.html in a variable
let fileContents = fs.readFileSync("./public/index.html", {encoding: "utf8"});
// Send a response to the client with the index.html file
response.write(fileContents);
response.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment