node.js

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'
  }
]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值