zoukankan      html  css  js  c++  java
  • nodejs之简单应用与运行

    1、nodejs第一个应用,入口函数为http.createServer()

    var http=require('http');//1.引入 http 模块
    
    //2.用 http 模块创建服务
    http.createServer(function(req,res){
      // 发送 HTTP 头部
      // HTTP 状态值: 200 : OK
      //设置 HTTP 头部,状态码是 200,文件类型是 html,字符集是 utf-8
      res.writeHead(200,{"Content-Type":"text/html;charset='utf-8'"});
      res.write('你好 nodejs');
      res.write('我是第一个 nodejs 程序');
      res.end(); /*结束响应*/
    }).listen(8001);

     2、在cmd或者terminal运行  

      node   fileName.js

      如果安装了supervisor ,可以使用 supervisor fileName.js 进行热部署,没有安装,请执行安装  

      npm -g install supervisor
  • 相关阅读:
    windows平台下一款强大的免费代理获取工具
    彻底搞懂Git Rebase
    line-height
    text-indent
    text-decoration
    text-align
    color
    CSS属性汇总
    font
    font-style
  • 原文地址:https://www.cnblogs.com/ywjfx/p/10396982.html
Copyright © 2011-2022 走看看