美文网首页NodeJs
node连接服务

node连接服务

作者: 简小园 | 来源:发表于2019-06-23 23:26 被阅读0次
  • 监听:等待客户端的连接
  • 端口:数字(一个端口 只有一个服务)

在终端运行js文件,在浏览器访问localhost:8080

//引入包
const http=require('http');
//请求
let server=http.createServer(function (req, res){
  res.write('abc');
  res.end();
  console.log("服务启动成功");
});
//监听8080端口号
server.listen(8080);

相关文章

网友评论

    本文标题:node连接服务

    本文链接:https://www.haomeiwen.com/subject/zytgqctx.html