node.js 之 http 架设

Node.js 安装配置

下载node.js安装mis

打开:cmd

cd到node.js安装目录下

输入nodejs --version

显示版本号,证明安装成功

在其根目录下建server.js

server.js代码

var http = require('http');

http.createServer(function (request, response) {

    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {'Content-Type': 'text/plain'});

    // 发送响应数据 "Hello World"
    response.end('Hello World
');
}).listen(8888);

// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');

  

命令行: cmd

cd到node.js根目录下

执行:node server.js

显示:Server running at http://127.0.0.1:8888/

浏览器打开:http://127.0.0.1:8888/ 

显示:hollow world!

运行成功!

Node.js 连接 MySQL

下载安装Mysql

原文地址:https://www.cnblogs.com/JamyWong/p/7624697.html