node.js
1、httpServer
//导入模块是require 类似于import java.io
const http = require('http');
//1:创建一个httpserver服务
http.createServer(function(request,response){
//浏览器怎么认识hello server!!
//告诉浏览器以text-plain去解析hello server 这段数据。 文本方式解析
response.writeHead(200,{'Content-type':'text/html'});
//给浏览器输出内容
response.end("<strong> hello server!!!<strong/>");
}).listen(8888);
console.log("您启动的服务成功!!!")
//2:监听一个端口8888
//3.启动运行服务 node httpserver.js
//4.在浏览器访问http://localhost:8888
2、node- 操作MYSQL数据库
1.安装mysql依赖
npm install mysql
//导入模块是require 类似于import java.io
const http = require('http');
//1:创建一个httpserver服务
http.createServer(function(request,response){
//浏览器怎么认识hello server!!
//告诉浏览器以text-plain去解析hello server 这段数据。 文本方式解析
response.writeHead(200,{'Content-type':'text/html'});
//给浏览器输出内容
response.end("<strong> hello server!!!<strong/>");
}).listen(8888);
console.log("您启动的服务成功!!!")
//2:监听一个端口8888
//3.启动运行服务 node httpserver.js
//4.在浏览器访问http://localhost:8888
结果
S E:\VsCode\NODEJS> node .\db.js
result = [
RowDataPacket {
id: 3,
name: '白玉',
password: '123456',
age: 22,
email: '1809562616@qq.com'
},
RowDataPacket {
id: 7,
name: '华阳',
password: 'abc',
age: 33,
email: '971446470@qq.com'
}
]