const express=require('express');
var server=express();
server.use('/a.html',function (req,res) {
res.send('ok').end();
})
server.get('/b.html',function (req,res) {
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});//只需要设置响应头的编码格式就好
res.write('write只能写字符串和buffer');
console.log(res.writeHead);
res.end();
})
server.listen(8080);```
转载于:https://my.oschina.net/u/3407699/blog/1624320