Node Note-Pray Lin

2. Create a service through http.createserver. Note the following anonymous function: req: request res: Response Response 3. Listen to listen to the port number and access address. 4. Use res.writeHead to set the web page status code and document content type. Res.end returns the result */ // start file: Nodexxx. js var HTTP = require(' HTTP ') // Var HTTP = require(' HTTP ') // var HTTP = require(' HTTP ' Http.createserver (function (req, res) {/* Set the response HTTP header. WriteHead (200, {" content-type ": "text/ HTML; charset = utF-8; Charset = utf-8 "}) console.log(' server received request, address :' + req.url) // will go 2 times // readFile and CSS fs.readFile('./resource/yuan.html', (err, data) => { res.writeHead(200, { 'Content-type': 'text/html; charset=UTF-8' }) res.end(data) }) fs.readFile('./resource/css/yuan.css', (err, data) => { res.writeHead(200, { 'Content-type': 'text/ CSS '}) res.end(data)}) /* Note that 1. Node has no web container concept localhost:3000/  world! }) server.listen(3000, '127.0.0.1') /* Server default port: 80 Tomcat default port: 8080 */Copy the code