node-服务器

原生:

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);
原文地址:https://www.cnblogs.com/shui1993/p/10395752.html