我正在学习如何使用Node.js,但目前遇到了问题。我无法在项目中加载css和js文件。我正在从CDN加载Bootstrap和Fontawesome,它们都能成功渲染。但是我的自定义css和js则一直无法加载。
我的文件夹路径如下:
folder
index.html
app.js
package.json
css
main.css
files
file.pdf
app.js内容:
var http = require('http');
var fs = require('fs');
//creating server
http.createServer(function (req, res) {
fs.readFile('index.html', function (err, html) {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write(html);
res.end();
});
}).listen(8080);