任务 6:编写 hello world web 程序

要求:

  • 编写 02-hello-world-server.js
  • 监听端口:8080
  • 当收到 HTTP 请求时,发送响应文本 hello world!
  • 用浏览器测试 web 程序
  • curl linux 命令行程序测试 web 程序

//cd nodejs-demo(目录已经存在,切换)

// touch 02-hello-world-serve.js

#!/usr/bin/node

const http = require('http');

http.createServer((req, res) => {

  res.end('hello world');

}).listen(8080);

//在浏览器中输入自己虚拟机的ipv4:端口号即可看到hello world、、// curl linux 命令行程序测试 web 程序

猜你喜欢

转载自blog.csdn.net/CHENpeiyingCHEN/article/details/82763945