小编Dom*_*öth的帖子

Nodejs 每个响应发送多个文件

我想每个响应向用户发送多个文件。例如,用户请求索引站点,而站点需要一些.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)

这有可能吗?或者有其他解决方案吗?

感谢您的帮助和解答!

javascript file-io response node.js

7
推荐指数
1
解决办法
4932
查看次数

标签 统计

file-io ×1

javascript ×1

node.js ×1

response ×1