Method description:
Send response content to the requesting client.
Before response.end() , response.write() can be executed multiple times.
grammar:
The code copy is as follows:
response.write(chunk, [encoding])
parameter:
chunk is a buffer or string that represents the sent content
encoding If chunk is a string, you need to specify encoding to explain its encoding method. By default, utf-8
example:
The code copy is as follows:
var http = require('http');
http.createServer(function(req, res){
res.writeHead(200, {'Content-type' : 'text/html'});
res.write('<h1>Node.js</h1>');
res.end('<p>Hello World</p>');
}).listen(3000);