D
D
Dvorak2016-09-17 21:13:30
Node.js
Dvorak, 2016-09-17 21:13:30

Why is express not serving files?

Hello. I wrote a simple script for returning statics:

const http = require('http'),
      express = require('express'),
      app = express();

app.use('/', express.static(__dirname + '/front-end/index.html'));
app.use('/add', express.static(__dirname + '/front-end/add.html'));
app.listen(8080);

At the same time, when going to the root, the static is not given away, but when going to /add, everything works. Moreover, if you replace '/' with '/another', for example, then everything works. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Amazing-Space-Invader, 2016-09-18
@allishappy

const http = require('http'),
      express = require('express'),
      app = express();

app.use(express.static(__dirname + '/front-end'));
app.use('/add', express.static(__dirname + '/front-end/add.html'));
app.listen(8080);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question