Basic Node and Express - Serve an HTML File

This is my code snippet but while I submitting the solution then it wont be submitted, I don’t know what is the issue

let express = require(‘express’);
let app = express();

app.get(“/”, function (req, res) {
res.send(__dirname+“/views/index.html”);
});

Your project link(s)

solution: boilerplate-express - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Basic Node and Express - Serve an HTML File

Link to the challenge:

Your code passes for me, make sure that your app is running and that you are using the preview link:

I got the solution, the above code won’t be work because I used there res.send() but it should be res.sendFile()

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.