繁体   English   中英

使用节点静态找不到Localhost页面

[英]Localhost page cannot be found using node-static

我正在尝试使用节点静态为静态文件提供服务。 稍后,我打算使用nssm将其作为Windows服务运行。 我以前已经运行过,但是不知道为什么,现在不起作用。

下面是我的代码:

var http = require('http');

var nStatic = require('node-static');

var fileServer = new nStatic.Server(); ---> I also tried new nStatic.Server('filepath')
//setting middleware

http.createServer(function (req, res) { 
        fileServer.serve(req, res);
}).listen(9000);

我在命令提示符下使用节点server.js启动服务器。 这就是我所看到的

http:// localhost:9000
http://本地主机:9000

节点-v 10.15.2 NPM -v 6.4.1

我必须使用完整路径,直到文件夹看到它的内容为止,由于我本地主机:9000从来不是一个文件,因此现在看来很明显。

我用了这样的东西-http:// localhost:9000 / Test / test.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM