认识 http
通过 http.createServer(callback) 创建一个http服务,通过 listen(port, callback) 监听端口。
const http = require('http')let app = http.createServer((req, res) => {console.log(req.url) // 打印 urlres.write('hello world') // response写入res.end() // 结束写入,与 write 函数结合使用})app.listen(8080, () => {console.log('listen on 8080 port...')})
解析get请求
queryString库的使用url库的使用
解析 post 请求
Buffer的使用app.on('data', callback)和app.end(callback)的使用
