Basic Node and Express - Serve an HTML File - Please help

I passed the challenge using a different way but what if I had to clear the challenge by just seeing the instructions provided?

https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express/serve-an-html-file

Here’s the code:

var path = require('path');
app.get('/', function(req, res){
  res.sendFile(path.join(__dirname + '/views/index.html'))
});

I don’t understand your question.

Do you have an example?

It doesn’t work, yet it seems to be the right code !

/** 3) Serve an HTML file */
app.get("/", function(req, res) {
res.sendFile(__dirname + ‘/views/index.html’);
});

???

app.get('/', function(req, res) {
res.sendFile(__dirname + '/views/index.html');
})

This is copy and pasted from my Github, and the code is the same as yours. It passed for me. What error are you getting?

Edit: Maybe this should have been a new topic?

3 Likes

Hello and thank you Ethan. I found my error, I just forgot to delete the code for the answers from the previous steps in Glitch. Obviously the validator validated me wrong. Thanks again Ethan!

2 Likes