zoukankan      html  css  js  c++  java
  • node.js 之 Hello,World in Node !

    创建一个js文件,把下面的内容粘贴进去,命名为helloworld.js。

    //加载 http 模块
    var http = require("http");
    
    //创建 http 服务
    http.createServer(function(req,res){
        
        //头内容
        res.writeHead(200,{"cintent-type":"text/plain"});
        
        //输出的信息
        res.end("Hello,World!
    ");
        
        }).listen(8124,'127.0.1.1');//绑定端口和IP
        
        console.log("服务运行在8124端口")//成功提示
    

     保存在你的电脑任何一个位置,然后打开你的node编辑器,通过CD命令进入helloworld.js所在的目录输入node helloworld.js 按回车!大功告成!

    一个简单的node服务器运行了!振奋人心!

  • 相关阅读:
    initData()
    moveUp()
    moveLeft()
    moveDown()
    函数具体分析
    Linux命令学习笔记
    RocketMQ使用记录
    solr安装记录
    centos7下面ruby的升级
    centos7下面装fastdfs
  • 原文地址:https://www.cnblogs.com/crafts/p/4380698.html
Copyright © 2011-2022 走看看