Answer the question
In order to leave comments, you need to log in
Why in node, when returning html, errors pop up in the console?
The page opens correctly.
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
var express = require('express'),
app = express(),
fs = require('fs');
app.use(express.static(__dirname + '/public'));
app.get('/', function (req, res) {
//res.sendFile(__dirname + '/index.html');
fs.readFile(__dirname + 'index.html', 'utf8', function(err, text) {
res.send(text);
});
});
app.listen(8200, function () {
console.log('Listen 8200 port');
});
app.get('*', function (req, res) {
res.render(__dirname + '/index.html');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question