麻雀虽小 五脏俱全
var http = require("http");
var url = require("url");
var router = {}
router["/api/get"] = function(req, res){
res.end("hello world")
}
console.log(router)
var handle = function(req ,res) {
var x = url.parse(req.url)
var _path = x.pathname;
router[_path]?router[_path](req,res):res.end("404");
}
var server = http.createServer(handle)
server.listen("9998")
网友评论