I'm very new to NodeJs and Express. here is my directory structure:
.
├── app.js
├── package-lock.json
├── package.json
├── views
│ ├── login.ejs
│ └── partials
│ ├── footer.ejs
│ └── header.ejs
└── www
├── anchor.html
└── index.html
I am trying to create an express route using app.get to load the contents of the 'www' directory but dynamically I used res.sendFile:
app.get("/mypath", function(req, res){
res.sendfile(__dirname + '/www/');
});
however it only lets me serve a single index.html file, and in the index.html file is an anchor link to the other html file 'anchor.html', but it wont load that file.
Is there an equivalent to sendFile that would let me serve the entire directory of 'www' BUT to the get route?
Aucun commentaire:
Enregistrer un commentaire