var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
// 发送响应数据 "Hello World"
response.end('Hello World\n');
}).listen(80);
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
listen方法有很多可选参数的,文档地址端口绑定在0.0.0.0或者ip
别人输入你的电脑的当前ip地址就可以吧!
在命令行中输入
ipconfig可以查看自己的ip把localhost改成自己的ip地址就能访问了