繁体   English   中英

Nodejs服务器创建未运行

[英]Nodejs Server Creation not running

我对nodejs非常陌生。 我发现此服务器创建程序很困难

var http =  require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}

http.createServer(onRequest).listen();

您必须提及要监听的端口号。

您的代码必须在侦听中包含端口号。

http.createServer(onRequest).listen(8080);

端口号8080已经在使用中...所以我用了

另一个端口号,例如8083。

暂无
暂无

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

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