0
I created a server with express:
const express = require('express');
const path = require('path');
const app = express();
app.use('/static', express.static('public'));
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, '/index.html'));
})
app.get('/addForm', function (req, res) {
res.sendFile(path.join(__dirname, '/addForm.html'));
})
app.listen(3001);
It reads all right, but when I added another page (/addForm.html) on the same level as /index.html it can’t read anymore.
This is the current structure:
What is the error in the console?
– novic
I guess I didn’t put all the right way
– novic
So Virgilio, no error appears on the console, simply states even if the path is wrong
– Flávia
The path is the same as index.html, since the two are in the same place, which could be wrong ?
– Flávia
Do a test and where you put the index.html, that is, in the
app.get('/'...
change the index.html for addForm.html and see if it works.– Esdras Xavier
how do you start the application in which folder? and which command line?
– novic