原生:

1 const http=require('http');
2 http.createServer((request,response)=>{
3   response.writeHead(200,{"Content-Type": "text/plain"});
4   response.write("Hello World");
5   response.end();
6 }).listen(8888)
1 const http=require('http');
2 function onRequest(req,res){
3   res.writeHead(200,{"Content-Type":"text/plain"});
4   res.write('Hello World');
5   res.end();
6 }
7 http.createServer(onRequest).listen(8888);

koa:

1 const Koa=require('koa');
2 const app=new Koa();
3 app.listen(8888)

express

1 const express=require('express');
2 const http=require('http');
3 const app=express();
4 const server=http.createServer(app);
5 server.listen(8081);

 

posted on 2019-02-18 15:11  沉默的末1993  阅读(124)  评论(0编辑  收藏  举报