const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
if(req.url!='/favicon.ico'){ //过滤favicon请求
console.log('request received!');
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
var name='rod johnson';
res.end(`Hello
${name}`);
}
}
);
server.listen(port, hostname, () => {
console.log(`服务运行于: http://${hostname}:${port}/`);
});
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!