# node-Express **Repository Path**: hcsy/node-Express ## Basic Information - **Project Name**: node-Express - **Description**: node-Express 学习 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-10-31 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # node-Express https://blog.csdn.net/oYuLian/article/details/83991191 #### 项目介绍 node-Express 学习 该框架还不支持import 和 export defualt 用 module.export 和 require() 代替 session 会话缓存管理 过滤器 全局异常捕获 model 依赖注入 查询索引 会话结合redis cheerio 爬虫使用 同步的数据库操作 Nodejs学习笔记(十二)--- 定时任务(node-schedule) https://www.cnblogs.com/zhongweiv/p/node_schedule.html #### 软件架构 软件架构说明 会话保持, 登录拦截, 查询失败返回 查询成功返回 日志打印 路由管理 系统时间 connection.query 请求数据库返回的数据本身就是JSON类型 request 请求别的接口的需要使用 JSON.parse() 处理 #### 安装教程 > https://blog.csdn.net/qq_26562641/article/details/76976112 ``` $ npm install express-generator -g // npm install 是安装任何第三方包的命令, express-generator -g 指在全局范围下安装名为 express-generator 的第三方包。 express myapp //指在当前命令行目录下创建一个名为myapp的文件夹用来做应用目录 cd myapp //到达我们的工作目录 npm install npm start // 或者 node app.js 或者其实还有很多的奇淫巧计 http://localhost:3000/ ``` 10点还款金:我的=>无卡支付=>下拉到底部=>还款金(自动更新,不用刷新页面): 11点饭票:首页=>饭票=>百元红包 14点商城无门槛红包: 15点9积分抢: #### 使用说明 1. xxxx 2. xxxx 3. xxxx #### 参与贡献 1. Fork 本项目 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 码云特技 #### console.log(req) console.log(res) secret: undefined, cookies: { _ga: 'GA1.1.540223451.1520913371', Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d: '1528722390,1528765983', UM_distinctid: '16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2', CNZZDATA1271233563: '1664648288-1531200104-|1534403261', rememberMe: 'STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=' }, signedCookies: {}, _parsedOriginalUrl: Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: null, query: null, pathname: '/stylesheets/style.css', path: '/stylesheets/style.css', href: '/stylesheets/style.css', _raw: '/stylesheets/style.css' } }, locals: {}, _startAt: [ 68354, 671517176 ], _startTime: 2018-11-12T07:16:01.836Z, writeHead: [Function: writeHead], __onFinished: null, statusCode: 304, statusMessage: 'Not Modified', [Symbol(outHeadersKey)]: { 'x-powered-by': [ 'X-Powered-By', 'Express' ], 'accept-ranges': [ 'Accept-Ranges', 'bytes' ], 'cache-control': [ 'Cache-Control', 'public, max-age=0' ], 'last-modified': [ 'Last-Modified', 'Wed, 31 Oct 2018 06:00:32 GMT' ], etag: [ 'ETag', 'W/"6f-166c8b58b11"' ] } } --------------------------------------------end---------------------------------------------------- [hcsy] 2018-11-12 15:16:01 GET /stylesheets/style.css 304 [object Object] IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: null, pipesCount: 0, flowing: true, ended: true, endEmitted: false, reading: false, sync: true, needReadable: false, emittedReadable: true, readableListening: false, resumeScheduled: true, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: true, decoder: null, encoding: null }, readable: true, domain: null, _events: {}, _eventsCount: 0, _maxListeners: undefined, socket: Socket { connecting: false, _hadError: false, _handle: TCP { reading: true, owner: [Circular], onread: [Function: onread], onconnection: null, writeQueueSize: 0, _consumed: true }, _parent: null, _host: null, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _events: { end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], drain: [Array], timeout: [Function: socketOnTimeout], data: [Function: bound socketOnData], error: [Function: socketOnError], close: [Function: bound socketOnClose], resume: [Function: onSocketResume], pause: [Function: onSocketPause] }, _eventsCount: 10, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: true, _bytesDispatched: 396, _sockname: null, _pendingData: null, _pendingEncoding: '', server: Server { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, _connections: 1, _handle: [Object], _usingSlaves: false, _slaves: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, _pendingResponseData: 0, maxHeadersCount: null, _connectionKey: '6::::3000', [Symbol(asyncId)]: 11 }, _server: Server { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, _connections: 1, _handle: [Object], _usingSlaves: false, _slaves: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, _pendingResponseData: 0, maxHeadersCount: null, _connectionKey: '6::::3000', [Symbol(asyncId)]: 11 }, _idleTimeout: 5000, _idleNext: TimersList { _idleNext: [Circular], _idlePrev: [Circular], _timer: [Object], _unrefed: true, msecs: 5000, nextTick: false }, _idlePrev: TimersList { _idleNext: [Circular], _idlePrev: [Circular], _timer: [Object], _unrefed: true, msecs: 5000, nextTick: false }, _idleStart: 5997, _destroyed: false, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': [Function: bound onParserExecute], _headers: [], _url: '', _consumed: true, socket: [Circular], incoming: [Circular], outgoing: null, maxHeaderPairs: 2000, onIncoming: [Function: bound parserOnIncoming] }, on: [Function: socketOnWrap], _paused: false, read: [Function], _consuming: true, _httpMessage: null, _peername: { address: '::1', family: 'IPv6', port: 55866 }, [Symbol(asyncId)]: 13, [Symbol(bytesRead)]: 0, [Symbol(asyncId)]: 15, [Symbol(triggerAsyncId)]: 13 }, connection: Socket { connecting: false, _hadError: false, _handle: TCP { reading: true, owner: [Circular], onread: [Function: onread], onconnection: null, writeQueueSize: 0, _consumed: true }, _parent: null, _host: null, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _events: { end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], drain: [Array], timeout: [Function: socketOnTimeout], data: [Function: bound socketOnData], error: [Function: socketOnError], close: [Function: bound socketOnClose], resume: [Function: onSocketResume], pause: [Function: onSocketPause] }, _eventsCount: 10, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: true, _bytesDispatched: 396, _sockname: null, _pendingData: null, _pendingEncoding: '', server: Server { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, _connections: 1, _handle: [Object], _usingSlaves: false, _slaves: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, _pendingResponseData: 0, maxHeadersCount: null, _connectionKey: '6::::3000', [Symbol(asyncId)]: 11 }, _server: Server { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, _connections: 1, _handle: [Object], _usingSlaves: false, _slaves: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, _pendingResponseData: 0, maxHeadersCount: null, _connectionKey: '6::::3000', [Symbol(asyncId)]: 11 }, _idleTimeout: 5000, _idleNext: TimersList { _idleNext: [Circular], _idlePrev: [Circular], _timer: [Object], _unrefed: true, msecs: 5000, nextTick: false }, _idlePrev: TimersList { _idleNext: [Circular], _idlePrev: [Circular], _timer: [Object], _unrefed: true, msecs: 5000, nextTick: false }, _idleStart: 5997, _destroyed: false, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': [Function: bound onParserExecute], _headers: [], _url: '', _consumed: true, socket: [Circular], incoming: [Circular], outgoing: null, maxHeaderPairs: 2000, onIncoming: [Function: bound parserOnIncoming] }, on: [Function: socketOnWrap], _paused: false, read: [Function], _consuming: true, _httpMessage: null, _peername: { address: '::1', family: 'IPv6', port: 55866 }, [Symbol(asyncId)]: 13, [Symbol(bytesRead)]: 0, [Symbol(asyncId)]: 15, [Symbol(triggerAsyncId)]: 13 }, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: { host: 'localhost:3000', connection: 'keep-alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', accept: 'text/css,*/*;q=0.1', referer: 'http://localhost:3000/', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9', cookie: '_ga=GA1.1.540223451.1520913371; Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d=1528722390,1528765983; UM_distinctid=16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2; CNZZDATA1271233563=1664648288-1531200104-%7C1534403261; rememberMe=STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=', 'if-none-match': 'W/"6f-166c8b58b11"', 'if-modified-since': 'Wed, 31 Oct 2018 06:00:32 GMT' }, rawHeaders: [ 'Host', 'localhost:3000', 'Connection', 'keep-alive', 'User-Agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', 'Accept', 'text/css,*/*;q=0.1', 'Referer', 'http://localhost:3000/', 'Accept-Encoding', 'gzip, deflate, br', 'Accept-Language', 'zh-CN,zh;q=0.9', 'Cookie', '_ga=GA1.1.540223451.1520913371; Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d=1528722390,1528765983; UM_distinctid=16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2; CNZZDATA1271233563=1664648288-1531200104-%7C1534403261; rememberMe=STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=', 'If-None-Match', 'W/"6f-166c8b58b11"', 'If-Modified-Since', 'Wed, 31 Oct 2018 06:00:32 GMT' ], trailers: {}, rawTrailers: [], upgrade: false, url: '/stylesheets/style.css', method: 'GET', statusCode: null, statusMessage: null, client: Socket { connecting: false, _hadError: false, _handle: TCP { reading: true, owner: [Circular], onread: [Function: onread], onconnection: null, writeQueueSize: 0, _consumed: true }, _parent: null, _host: null, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: false, endEmitted: false, reading: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: null, _events: { end: [Array], finish: [Function: onSocketFinish], _socketEnd: [Function: onSocketEnd], drain: [Array], timeout: [Function: socketOnTimeout], data: [Function: bound socketOnData], error: [Function: socketOnError], close: [Function: bound socketOnClose], resume: [Function: onSocketResume], pause: [Function: onSocketPause] }, _eventsCount: 10, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, allowHalfOpen: true, _bytesDispatched: 396, _sockname: null, _pendingData: null, _pendingEncoding: '', server: Server { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, _connections: 1, _handle: [Object], _usingSlaves: false, _slaves: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, _pendingResponseData: 0, maxHeadersCount: null, _connectionKey: '6::::3000', [Symbol(asyncId)]: 11 }, _server: Server { domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, _connections: 1, _handle: [Object], _usingSlaves: false, _slaves: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, _pendingResponseData: 0, maxHeadersCount: null, _connectionKey: '6::::3000', [Symbol(asyncId)]: 11 }, _idleTimeout: 5000, _idleNext: TimersList { _idleNext: [Circular], _idlePrev: [Circular], _timer: [Object], _unrefed: true, msecs: 5000, nextTick: false }, _idlePrev: TimersList { _idleNext: [Circular], _idlePrev: [Circular], _timer: [Object], _unrefed: true, msecs: 5000, nextTick: false }, _idleStart: 5997, _destroyed: false, parser: HTTPParser { '0': [Function: parserOnHeaders], '1': [Function: parserOnHeadersComplete], '2': [Function: parserOnBody], '3': [Function: parserOnMessageComplete], '4': [Function: bound onParserExecute], _headers: [], _url: '', _consumed: true, socket: [Circular], incoming: [Circular], outgoing: null, maxHeaderPairs: 2000, onIncoming: [Function: bound parserOnIncoming] }, on: [Function: socketOnWrap], _paused: false, read: [Function], _consuming: true, _httpMessage: null, _peername: { address: '::1', family: 'IPv6', port: 55866 }, [Symbol(asyncId)]: 13, [Symbol(bytesRead)]: 0, [Symbol(asyncId)]: 15, [Symbol(triggerAsyncId)]: 13 }, _consuming: false, _dumped: true, next: [Function: next], baseUrl: '', originalUrl: '/stylesheets/style.css', _parsedUrl: Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: null, query: null, pathname: '/stylesheets/style.css', path: '/stylesheets/style.css', href: '/stylesheets/style.css', _raw: '/stylesheets/style.css' }, params: {}, query: {}, res: ServerResponse { domain: null, _events: { finish: [Function: bound resOnFinish] }, _eventsCount: 1, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: false, upgrading: false, chunkedEncoding: false, shouldKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: true, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: 0, _hasBody: false, _trailer: '', finished: true, _headerSent: true, socket: null, connection: null, _header: 'HTTP/1.1 304 Not Modified\r\nX-Powered-By: Express\r\nAccept-Ranges: bytes\r\nCache-Control: public, max-age=0\r\nLast-Modified: Wed, 31 Oct 2018 06:00:32 GMT\r\nETag: W/"6f-166c8b58b11"\r\nDate: Mon, 12 Nov 2018 07:16:01 GMT\r\nConnection: keep-alive\r\n\r\n', _onPendingData: [Function: bound updateOutgoingData], _sent100: false, _expect_continue: false, req: [Circular], locals: {}, _startAt: [ 68354, 671517176 ], _startTime: 2018-11-12T07:16:01.836Z, writeHead: [Function: writeHead], __onFinished: null, statusCode: 304, statusMessage: 'Not Modified', [Symbol(outHeadersKey)]: { 'x-powered-by': [Array], 'accept-ranges': [Array], 'cache-control': [Array], 'last-modified': [Array], etag: [Array] } }, _startAt: [ 68354, 668679294 ], _startTime: 2018-11-12T07:16:01.833Z, _remoteAddress: '::1', body: {}, secret: undefined, cookies: { _ga: 'GA1.1.540223451.1520913371', Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d: '1528722390,1528765983', UM_distinctid: '16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2', CNZZDATA1271233563: '1664648288-1531200104-|1534403261', rememberMe: 'STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=' }, signedCookies: {}, _parsedOriginalUrl: Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: null, query: null, pathname: '/stylesheets/style.css', path: '/stylesheets/style.css', href: '/stylesheets/style.css', _raw: '/stylesheets/style.css' } } --------------------------------------------br---------------------------------------------------- ServerResponse { domain: null, _events: { finish: [Function: bound resOnFinish] }, _eventsCount: 1, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: false, upgrading: false, chunkedEncoding: false, shouldKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: true, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: 0, _hasBody: false, _trailer: '', finished: true, _headerSent: true, socket: null, connection: null, _header: 'HTTP/1.1 304 Not Modified\r\nX-Powered-By: Express\r\nAccept-Ranges: bytes\r\nCache-Control: public, max-age=0\r\nLast-Modified: Wed, 31 Oct 2018 06:00:32 GMT\r\nETag: W/"6f-166c8b58b11"\r\nDate: Mon, 12 Nov 2018 07:16:01 GMT\r\nConnection: keep-alive\r\n\r\n', _onPendingData: [Function: bound updateOutgoingData], _sent100: false, _expect_continue: false, req: IncomingMessage { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: [Object], length: 0, pipes: null, pipesCount: 0, flowing: true, ended: true, endEmitted: false, reading: false, sync: true, needReadable: false, emittedReadable: true, readableListening: false, resumeScheduled: true, destroyed: false, defaultEncoding: 'utf8', awaitDrain: 0, readingMore: true, decoder: null, encoding: null }, readable: true, domain: null, _events: {}, _eventsCount: 0, _maxListeners: undefined, socket: Socket { connecting: false, _hadError: false, _handle: [Object], _parent: null, _host: null, _readableState: [Object], readable: true, domain: null, _events: [Object], _eventsCount: 10, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: true, _bytesDispatched: 396, _sockname: null, _pendingData: null, _pendingEncoding: '', server: [Object], _server: [Object], _idleTimeout: 5000, _idleNext: [Object], _idlePrev: [Object], _idleStart: 5997, _destroyed: false, parser: [Object], on: [Function: socketOnWrap], _paused: false, read: [Function], _consuming: true, _httpMessage: null, _peername: [Object], [Symbol(asyncId)]: 13, [Symbol(bytesRead)]: 0, [Symbol(asyncId)]: 15, [Symbol(triggerAsyncId)]: 13 }, connection: Socket { connecting: false, _hadError: false, _handle: [Object], _parent: null, _host: null, _readableState: [Object], readable: true, domain: null, _events: [Object], _eventsCount: 10, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: true, _bytesDispatched: 396, _sockname: null, _pendingData: null, _pendingEncoding: '', server: [Object], _server: [Object], _idleTimeout: 5000, _idleNext: [Object], _idlePrev: [Object], _idleStart: 5997, _destroyed: false, parser: [Object], on: [Function: socketOnWrap], _paused: false, read: [Function], _consuming: true, _httpMessage: null, _peername: [Object], [Symbol(asyncId)]: 13, [Symbol(bytesRead)]: 0, [Symbol(asyncId)]: 15, [Symbol(triggerAsyncId)]: 13 }, httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: { host: 'localhost:3000', connection: 'keep-alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', accept: 'text/css,*/*;q=0.1', referer: 'http://localhost:3000/', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9', cookie: '_ga=GA1.1.540223451.1520913371; Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d=1528722390,1528765983; UM_distinctid=16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2; CNZZDATA1271233563=1664648288-1531200104-%7C1534403261; rememberMe=STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=', 'if-none-match': 'W/"6f-166c8b58b11"', 'if-modified-since': 'Wed, 31 Oct 2018 06:00:32 GMT' }, rawHeaders: [ 'Host', 'localhost:3000', 'Connection', 'keep-alive', 'User-Agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36', 'Accept', 'text/css,*/*;q=0.1', 'Referer', 'http://localhost:3000/', 'Accept-Encoding', 'gzip, deflate, br', 'Accept-Language', 'zh-CN,zh;q=0.9', 'Cookie', '_ga=GA1.1.540223451.1520913371; Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d=1528722390,1528765983; UM_distinctid=16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2; CNZZDATA1271233563=1664648288-1531200104-%7C1534403261; rememberMe=STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=', 'If-None-Match', 'W/"6f-166c8b58b11"', 'If-Modified-Since', 'Wed, 31 Oct 2018 06:00:32 GMT' ], trailers: {}, rawTrailers: [], upgrade: false, url: '/stylesheets/style.css', method: 'GET', statusCode: null, statusMessage: null, client: Socket { connecting: false, _hadError: false, _handle: [Object], _parent: null, _host: null, _readableState: [Object], readable: true, domain: null, _events: [Object], _eventsCount: 10, _maxListeners: undefined, _writableState: [Object], writable: true, allowHalfOpen: true, _bytesDispatched: 396, _sockname: null, _pendingData: null, _pendingEncoding: '', server: [Object], _server: [Object], _idleTimeout: 5000, _idleNext: [Object], _idlePrev: [Object], _idleStart: 5997, _destroyed: false, parser: [Object], on: [Function: socketOnWrap], _paused: false, read: [Function], _consuming: true, _httpMessage: null, _peername: [Object], [Symbol(asyncId)]: 13, [Symbol(bytesRead)]: 0, [Symbol(asyncId)]: 15, [Symbol(triggerAsyncId)]: 13 }, _consuming: false, _dumped: true, next: [Function: next], baseUrl: '', originalUrl: '/stylesheets/style.css', _parsedUrl: Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: null, query: null, pathname: '/stylesheets/style.css', path: '/stylesheets/style.css', href: '/stylesheets/style.css', _raw: '/stylesheets/style.css' }, params: {}, query: {}, res: [Circular], _startAt: [ 68354, 668679294 ], _startTime: 2018-11-12T07:16:01.833Z, _remoteAddress: '::1', body: {}, secret: undefined, cookies: { _ga: 'GA1.1.540223451.1520913371', Hm_lvt_1ad0a5c62a113bb874be8bb514b0a70d: '1528722390,1528765983', UM_distinctid: '16482f2f519515-093d3bacf4307a-3c604504-1fa400-16482f2f51a4d2', CNZZDATA1271233563: '1664648288-1531200104-|1534403261', rememberMe: 'STkL4t+R6tvthLlQVaBH68f4ao5roC6bATN2owwqh8VHkwDMETqowP0ieXRaCHfHY54kR3RsNXY8yMvqgQ60x6kh3yZMm+zRRX2jcKprU7Gbe3z90b70tq6ap5HR23YSZ8+uI2O8K8ajx4O+u44wCnX7qrtn7lyGbyrCAf0gARwof3bK6vbcPLr6AKnVkuX+fGc7UsutA1hd9oDZtCgVh/A0xJSwwhfpp2Wvy6KuPX2VaRSR/4Xz2dP+pCeApPNmkCQghfk+Yux1ItX+TE+7FU+92XWfXtTxrF0lrez5SPpKHII5ow0pK5iuRKpWVLzTe4oe1l9IJ4mRTZQtj7ISYhPH3J5Uszv/jazPZVMm1TBv3bYxzuM+I7mE0C6Uds417yv4zJBuho+20I9ytMulUzuxQ0wERqK3Z602H5IqjYVfG926G96cfw2IqSfva3NcRowT4zhwJ+B1UCbj1CD4XiOeG1lq0+Ekqq0T0ZVfYnCrdsTboKXCRMnkrrJHkZZqnhPfXV0zGIkZq57F2W/FFPawhOI4b2ZiPtVkK2jP2LI=' }, signedCookies: {}, _parsedOriginalUrl: Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: null, query: null, pathname: '/stylesheets/style.css', path: '/stylesheets/style.css', href: '/stylesheets/style.css', _raw: '/stylesheets/style.css' } }, locals: {}, _startAt: [ 68354, 671517176 ], _startTime: 2018-11-12T07:16:01.836Z, writeHead: [Function: writeHead], __onFinished: null, statusCode: 304, statusMessage: 'Not Modified', [Symbol(outHeadersKey)]: { 'x-powered-by': [ 'X-Powered-By', 'Express' ], 'accept-ranges': [ 'Accept-Ranges', 'bytes' ], 'cache-control': [ 'Cache-Control', 'public, max-age=0' ], 'last-modified': [ 'Last-Modified', 'Wed, 31 Oct 2018 06:00:32 GMT' ], etag: [ 'ETag', 'W/"6f-166c8b58b11"' ] } } --------------------------------------------end---------------------------------------------------- app.post('/login',urlencodedParser,function(req,res){ //console.log(req); console.log(req.body); var user_name=req.body.user; var password=req.body.password; console.log("User name = "+user_name+", password is "+password); res.end("yes"); }); app.get('/about', function (req, res) { //设置about页面的路由 用 '/about' 表示 var num = req.query.num; res.send("你获取的get数据为:" + num); }) 简单来说就是 如果服务器端没有数据返回到客户端 那么就可以用 res.end 但是 如果 服务器端有数据返回到客户端 这个时候必须用res.send ,不能用 res.end(会报错) 还有一个res.json() 方法功能和res.send()效果相似 res.json(null); res.json({user:'tobi'}); res.status(500).json({error:'message'}); res.send(new Buffer('whoop')); res.send({some:'json'}); res.send('

some html

'); res.status(404).send('Sorry, we cannot find that!'); res.status(500).send({ error: 'something blew up' }); res.set('Content-Type', 'text/html'); res.send(new Buffer('

some html

')); XYP: https://auth.yemadai.com/login XYP: zhangjihao@3c-buy.com XYP: YYO2251sf XYP: 2672949309@qq.com app.get('/user', (req, res) => { connection.connect()//连接数据库 connection.query('SELECT * FROM `user`', function (err, rows, fields) { loggerInfo.info("男男女女女", err, rows, fields); if (err) { res.send({ code: 500, data: "操作失败", msg: "" }); throw err } console.log('The solution is: ', rows, fields); res.json(rows); }) connection.end()//关闭连接数据库 //在res.json()之后还是可以执行的 }) //查询 app.get('/userGet', function (req, res) { let sqlString = "SELECT * FROM `user`"; // mydb.query(sqlString, function (error, results, fields) { // loggerInfo.info("操作userGet",error, results, fields); // res.json(error); // }); connection.query(sqlString, function (error, results, fields) { console.log(product); loggerInfo.info("操作", error, results); if (error) throw error; res.json(results); }); return; })