我想每个响应向用户发送多个文件。例如,用户请求索引站点,而站点需要一些.png、css 等。
用户只得到一个包含所有他需要的包。这就是想法。
所以我的想法是它会以这样的方式实现:
res.writeHead(200, {'Content-Type': 'text/html'});
var content = fs.readFileSync(applicationPath + "index.html");
res.write(content);
content = fs.readFileSync(applicationPath + "images/logo.png");
res.write(content);
content = fs.readFileSync(applicationPath + "index.css");
res.write(content);
res.end();
Run Code Online (Sandbox Code Playgroud)
这有可能吗?或者有其他解决方案吗?
感谢您的帮助和解答!