Answer the question
In order to leave comments, you need to log in
How to set dynamic search for files in a request?
How to make request processing for all requests, and not just for /
?
For example, if a request comes in /user, /doc/lib or / - they were processed in one app.get, and not writing many app.get().
And if they found a file, they gave it away. Those. automatic file search occur on request.
More precisely, how do we get the request parameter app.get('/',
so that it is any, and not just for / and process this request.
app.get('/', function (req, res) {
var file = fs.readFileSync('pages/ + 'index.html', 'utf8');
res.send(file);
});
Answer the question
In order to leave comments, you need to log in
Use , but all static files must be located exactly in the specified directory
More details here: https://expressjs.com/en/starter/static-files.htmlapp.use(express.static('pages'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question