欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

url浅析

程序员文章站 2022-07-12 14:58:12
...

url浅析
路径解析

const http = require('http');
const url = require('url');
const server = http.createServer((req, res) => {
  let path = url.parse(req.url);
  res.write("url is" + req.url + "\n");
  res.end("PATH is" + path.pathname + "\n");
});
let port = process.env.NODE_PORT || 8080;
server.listen(port, () => {
    console.log("Server started at: " + port);
});
相关标签: url