node
success-happiness
小菜鸟
展开
-
express helloWorld
1、在文件夹创建一个package.jsonnpm init 2、安装 Express 并将其保存到依赖列表中npm install express --save 3、创建一个helloWorld.js文件var express = require("express"); var app = express();app.get('/',function (req,res) { res.sen原创 2017-08-08 22:04:05 · 260 阅读 · 0 评论 -
node helloworld
// 引包 const http = require('http');// 初始化ip和端口 const hostname = "127.0.0.1"; const port = "3000";// 创建服务器 const server = http.createServer((req,res)=>{ // 设置状态码 res.statusCode = 200; //原创 2017-07-25 17:56:01 · 175 阅读 · 0 评论 -
express+mysql连接池
db.jsvar mysql=require("mysql");// 创建连接池 var pool = mysql.createPool({ host: 'localhost', user: 'root', password: 'root', database: 'test1', port: 3306 });// 连接公用方法 var query=functi原创 2017-09-15 14:29:06 · 3430 阅读 · 1 评论