0

I have the following express server:

path = require('path');
express = require('express');
app = express();

app.use(express.static(path.join(__dirname)));

server = app.listen(80, function () {
    host = 'localhost';
    port = server.address().port;
    console.log('listening on http://'+host+':'+port+'/');
});

It supose to send me all files in the directory when i load http://localhost in the navigator, but it send me this text:

Cannot GET /

Why it happens??? Thanks for helping anyway.

  • 1
    Possible duplicate of [Express.js - any way to display a file/dir listing?](https://stackoverflow.com/questions/6294186/express-js-any-way-to-display-a-file-dir-listing) – Luca Kiebel Jun 27 '18 at 17:55
  • well you are missing the '/' route. – WilomGfx Jun 27 '18 at 17:56
  • There is a diference between express.js any way to display a file/dir listing, and an error happened with the answer of that question. At least I suppose. Correct me if im wrong. –  Jun 27 '18 at 18:30
  • It doesnt work with `app.use('/',express.static(path.join(__dirname)));` –  Jun 27 '18 at 18:32

0 Answers0