最新公告:
1.安装nodejs服务(从官网下载安装),node相当于apache服务器
2.在自己定义的目录下新建服务器文件如 server.js
例如,我在E:PhpProjecthtml5websocket下创建了server.js文件
var http = require("http")//引入http模块
//开启服务,监听8888端口
//端口号最好为6000以上
var server = http.createServer(function(req,res){
console.log("有客户端连接")//创建连接成功显示在后台
node.js怎样建个后台服务?可以新建server.js文件,代码如下: var http = require("http") http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/html"}) response.end("Woohoo!") }).listen(8080) 为了方便调试,安装 hotnode npm install -g hotnode hotnode server.js
版权所有 稷山县乐盈传动系统有限公司 网址:www.sxcpbc.cn 邮箱:uayecj3@sxcpbc.cn
地址:稷山县