Serve static folder using nodejs and express js

I'm trying to serve static files using nodejs and express js. In the code I have:

server.use('/public', express.static(__dirname + '/public'));

But when I try to enter locahost:myPort/public i get

Cannot GET /public/

I have some two other mappings: "/search.html" and "/download.html" and those pages works fine. What I would like to get is the files list, which are in the public folder.

Is it possible to get such results?

What you are looking for is possible through the use of the serve-index middleware. https://github.com/expressjs/serve-index

npm install serve-index

.

var serveIndex = require('serve-index');

app.use('/public', serveIndex('/public'));