最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

无法使用节点静态找到Localhost页面

IT培训 admin 13浏览 0评论

无法使用节点静态找到Localhost页面

我正在尝试使用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

节点-v 10.15.2npm -v 6.4.1

谁能告诉我我做错了什么吗?

回答如下:

我不得不使用完整的路径,直到文件夹看到它的内容为止,由于我的本地主机:9000从来都不是文件,所以现在看起来很明显。

我使用了类似的内容-http://localhost:9000/Test/test.txt

无法使用节点静态找到Localhost页面

我正在尝试使用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

节点-v 10.15.2npm -v 6.4.1

谁能告诉我我做错了什么吗?

回答如下:

我不得不使用完整的路径,直到文件夹看到它的内容为止,由于我的本地主机:9000从来都不是文件,所以现在看起来很明显。

我使用了类似的内容-http://localhost:9000/Test/test.txt

发布评论

评论列表 (0)

  1. 暂无评论