Nodejs实战 (base v16.18.1)
《nodejs实战》学习过程中涉及到核心模块学习记录
《nodejs实战》学习过程中涉及到核心模块学习记录
http.ceateServer(requestListener?: http.RequestListener): http.Server
const http = require("http")
const server = http.createServer((req, res) => {
const [pathname, query] = req.url.split('?')
// router parser
if(pathname === '/getData' && req.method === 'GET') {
res.setHeader('Content-Type', 'text/plain;charset=utf-8')
res.end(`get请求参数为:${query}`)
} else if(pathname === '/postData' && req.method === 'POST') {
let buffer = ''
req.on('data', (chunk) => {
buffer += chunk.toString()
})
req.on('end',() => {
res.end(JSON.stringify(buffer))
})
}else if(pathname === '/') {
res.setHeader('Content-Type', 'text/html')
res.write(`<h1>hello world</h1>`)
res.end()
} else {
res.writeHead(404, {'Content-Type': 'text/plain'})
res.end('404 NOT FOUND')
}
})
server.listen(8888);
The node:net module provides an asynchronous network API for creating stream-based TCP or IPC servers (net.createServer()) and clients
提供了两个用于处理 URL 的 API:一个是特定于 Node.js 的遗留 API,另一个是实现 Web 浏览器使用的相同WHATWG URL 标准的新 AP
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.