Node
阳光的男夹克
心软的人没遇到 小火慢炖的粥掺了水
展开
-
node 操作 cookie
解析 cookie const http = require('http'); const server = http.createServer((req,res) => { // 解析 cookie req.cookie = {} const cookieStr = req.headers.cookie || '' // k1=v1;k2=v2;k3=v3 cookieStr.split(';').forEach(item => { if (!item) {原创 2021-03-07 16:55:26 · 68 阅读 · 0 评论 -
Node 操作 Mysql
在项目中安装 Mysql npm install mysql 使用方法 const mysql = require('mysql') // 创建链接对象 const con = mysql.createConnection({ host: 'localhost', // 地址 user: 'root', // 用户名 password: 'Mysql_2018', // 密码 port: '3306', // 端口 database: 'myblog' // 数据原创 2021-03-07 16:29:22 · 52 阅读 · 1 评论 -
Node 路由
获取路由 const http = require('http'); const server = http.createServer((req,res) => { const url = req.url const path = url.split('?')[0] res.end(path) }) server.listen(8000)原创 2021-03-06 20:35:27 · 71 阅读 · 0 评论 -
Node HTTP请求
Node HTTP请求 const http = require('http'); const server = http.createServer((req,res) => { req.end('hello world'); }) server.listen(8000) git 请求,即客户端向 server 端获取数据,如查询列表。是通过 querystring 来传递数据 const http = require('http'); const querystring = requi原创 2021-03-06 20:34:48 · 138 阅读 · 0 评论 -
Node 模块化开发基础
node.js 模块化开发规范 Node.js 规定了 javascript 文件就是一个模块,模块内部定义的变量和函数默认情况下在外部无法得到。 模块内部可以使用 exports 对象进行成员导出,使用 require 方法导入其他模块 a.js 导出 var a = 12; function fn() { console.log("我被调用了") } // 使用exports导出,也可以用 module.exports 导出 exports.a = a; // module.exports.a =原创 2021-02-12 14:32:34 · 111 阅读 · 1 评论