const url=require('url')
const http=require('http');
//创建服务对象
//request是对浏览器请求报文的封装对象
//reponse是对服务器返回报文的封装对象
const server=http.createServer((request,response)=>{
//解析resquest.url
let res=url.parse(request.url,true);
//路径
let pathname=res.pathname;
console.log(pathname);
//查询字符串
let keyword=res.query.keyword;
console.log(keyword);
response.end('url')
})
//监听端口,启动服务
server.listen(9000,()=>{
console.log('服务已经启动...');
})
709_http模块_提取http报文的URL路径和查询字符串
- 本文链接: http://lzkpersonal.com.cn/2023/07/09/709-http模块-提取http报文的URL路径和查询字符串/
- 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!