zoukankan      html  css  js  c++  java
  • node sever

    一、基础创建服务器

    // 引入Http
    var http = require("http");
    
    // 创建服务器
    http.createServer(function(request,response){
           // 定义响应头部
        response.writeHead(200,{'Content-Type': 'text/plain'});
           // 定义响应内容
        response.end('Hello World
    ');
    }).listen(8888); // 定义服务器端口号为8888
    
    // 控制台输出以下内容
    console.log('Sever running at http://127.0.0.1:8888/');

    二、VS2017创建node程序

    文件 - 新建 - 项目 - 其他语言 - JavaScript - Node.js

    (这里以 “空白Node.js Web 应用程序” 为例)

    创建解决方案成功后,如下图:

    选好调试浏览器,按下F5生成即可

    可打开server.js,该文件为自动创建的服务器代码。

  • 相关阅读:
    CodeForces
    CodeForces
    Simple Robot Gym
    Gym
    Java课程03总结
    Java课程03总结
    判断字符串是否回文
    Java课程02总结
    有关二进制原码、反码、补码
    Java课程01总结
  • 原文地址:https://www.cnblogs.com/leona-d/p/8095993.html
Copyright © 2011-2022 走看看