摘要: const mysql = require("mysql");const co = require("co-mysql");let conn = mysql.createPool({ host: "localhost", user: "root", password: "root", databas 阅读全文
posted @ 2021-04-02 11:01 莣ㄋ噯 阅读(79) 评论(0) 推荐(0)
摘要: /* 设置签名的 Cookie 密钥。 */app.keys = ["123", "456", "789", "111"];app.use(async ctx => { ctx.cookies.set("name", "age", { /* 设置cookies有效期 */ maxAge: 9 * 2 阅读全文
posted @ 2021-04-02 09:57 莣ㄋ噯 阅读(219) 评论(0) 推荐(0)
摘要: 第一种方法通过设置头部处理跨域 app.use(async (ctx, next) => { ctx.set("Access-Control-Allow-Origin", "http://192.168.31.45:63341"); /* 处理跨域携带cookie时出现的问题 */ ctx.set( 阅读全文
posted @ 2021-04-02 09:43 莣ㄋ噯 阅读(551) 评论(0) 推荐(0)
摘要: const serve = require("koa-static");const Router = require("koa-router"); app.use(serve("../static", { /* 文件的超时时间 */ maxage: 7 * 24 * 60 * 60 * 1000, 阅读全文
posted @ 2021-04-02 09:09 莣ㄋ噯 阅读(228) 评论(0) 推荐(0)
摘要: /* 可以添加的全局属性 */// app.context.a=12; /* get请求的数据 */// ctx.query/* 客户端的ip */// ctx.ip/* 请求头 */// ctx.headers/* 设置请求头 */// ctx.set('content-type', json`) 阅读全文
posted @ 2021-04-01 16:54 莣ㄋ噯 阅读(1607) 评论(0) 推荐(0)
摘要: 入口app.js const koa = require("koa");const app = new koa();const Router = require('koa-router');const router = new Router();/* 引用路由user */const user = 阅读全文
posted @ 2021-04-01 15:38 莣ㄋ噯 阅读(196) 评论(0) 推荐(0)
摘要: const express = require("express");const port = 8080;const app = express();/* 解析post */const body = require("body-parser");/* 解析cookie */const cookieP 阅读全文
posted @ 2021-03-31 17:10 莣ㄋ噯 阅读(77) 评论(0) 推荐(0)
摘要: const http = require("http");const mysql = require("mysql");const querystring = require("querystring");const co = require("co-mysql");const url = requ 阅读全文
posted @ 2021-03-30 11:13 莣ㄋ噯 阅读(249) 评论(0) 推荐(0)
摘要: ①安装服务:mysqld --install ②初始化: mysqld --initialize --console ③开启服务:net start mysql ④关闭服务:net stop mysql ⑤登录mysql:mysql -u root -p Enter PassWord:(密码) ⑥修 阅读全文
posted @ 2021-03-29 17:36 莣ㄋ噯 阅读(1036) 评论(0) 推荐(0)
摘要: 增 INSERT INSERT INTO <表> (字段,...) VALUES (值,...); INSERT INTO `user_table` (`username`,`password`) VALUES ('lisi',‘654321’); 删 DELETE DELETE FROM <表> 阅读全文
posted @ 2021-03-29 17:17 莣ㄋ噯 阅读(45) 评论(0) 推荐(0)