node的http模块

 1 // 引入http模块
 2 let http = require('http');
 3 
 4 /*
 5 // 创建一个web服务器
 6 let server = http.createServer((req, res)=>{
 7     res.end('Hello, itLike~~~~~~~~~~~ha ha ha');
 8 });
 9 
10 // 监听
11 server.listen(8080, '127.0.0.1', ()=>{
12     console.log('8080端口上的Node服务器已经启动了!');
13 });
14 */
15 
16 // 创建一个web服务器
17 http.createServer((req, res)=>{
18     res.end('Hello, itLike~~~~~~~~~~~ha ha ha');
19 }).listen(8080, '127.0.0.1', ()=>{
20     console.log('8080端口上的Node服务器已经启动了!');
21 });

猜你喜欢

转载自www.cnblogs.com/zhangzhengyang/p/11110458.html