How to display the contents of a requested html file to the user's browser?

Here's some of what I have:

const fs = require('fs');

const url = require('url');

var path = req.url;

var pathString = path.toString();

var responsePath = pathString.subString(1); //to get rid of the '/' at the beginning of the path

fs.open(responsePath, 'r', (err, fd) => {

const fileContents = fs.readFileSync(responsePath, 'utf8')

response.write(fileContents);

response.end(fileContents);

I know I probably don't need both response.write(fileContents) and response.end(fileContents), I was just testing them both out. Currently, I can display the file contents to the console fine, but it will not display on the webpage. I get: ERROR ENOENT: no such file or directory, open 'favicon.ico', when I try to access the test.html file.

/r/node Thread Parent