node 创建服务器方法

方法一

let http = require('http')
let httpserver = http.createServer(function(req,res){
    res.writeHead(200,{'Content-type':'text/plain'})
    res.end("hello!666666")
})
httpserver.listen(3000,()=>{
    console.log('正在监听 localhost:3000');
});

方法二

let express = require('express');
let app = express();
app.listen(3000,()=>{
    console.log('正在监听 localhost:3000');
});
posted @ 2021-07-17 22:33  likepoems  阅读(26)  评论(0编辑  收藏  举报