一、首先要保证自己的电脑有 NodeJS环境,然后在谈其他的
二、创建文件
三、复制代码
var http = require('http');
// axios 请求拦截器request&响应拦截器response
http.createServer(function (request, response) {
// 发送 HTTP 头部
// HTTP 状态值: 200 : OK
// 内容类型: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// 发送响应数据 "Hello World"(响应数据的最后一段代码)
response.end('Hello World\n');
}).listen(8888);
// 终端打印如下信息//主机名127.0.0.1:8888
console.log('Server running at http://127.0.0.1:8888/');
四、运行命令
五、运行结果