i want to get css file via Node.js localhost. index.php load correct, style.css can't be loaded.
my structure files
app.js views
index.php
css
style.css
my app.js
const http = require('http');
const fs = require('fs');
const hostname = '127.0.0.1';
const port = 3000;
fs.readFile('views/index.php', (err, html) => {
if (err) {
throw err;
}
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-type', 'text/html');
res.write(html);
res.end();
});
server.listen(port, hostname, () => {
console.log('Server started on port ' + port + (Date.now()));
console.log('address ' + hostname);
});
});
my index.php
<html>
<head>
<link rel="stylesheet" href="css/style.css" />
<title>title</title>
</head>
</html>