Tell us what’s happening:
Describe your issue in detail here.
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/112.0.0.0 Safari/537.36 Edg/112.0.1722.58
Challenge: Basic Node and Express - Serve an HTML File
Link to the challenge:
To send File as HTML you need to use res.render
function,
first send the views folder
app.send("views", pathToViews);
then
res.render("filename");
Use res.sendFile
and pass it __dirname
concatenated with the folder/file path to the HTML file in the views
folder.
res.sendFile(__dirname + '/someFolder/someFile.html')
Or use path.join
const path = require('path')
res.sendFile(path.join(__dirname, someFolder, someFile.html))
system
Closed
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.