nd24h_5_1.js var http = require('http');var url = require('url');http.createServer(function (req, res) { // req.url包含请求url字符串 // url模块的parse()方法根据url字符串解析出一个url对象 var reqUrl = url.parse(req.ur
var http = require('http'); var url = require('url'); http.createServer(function (req, res) { // req.url包含请求url字符串 // url模块的parse()方法根据url字符串解析出一个url对象 var reqUrl = url.parse(req.url); var text = ""; text += "path: " + reqUrl.path + "\n"; text += "pathname: " + reqUrl.pathname + "\n"; text += "search: " + reqUrl.search + "\n"; text += "query: " + reqUrl.query + "\n"; text += "hash: " + reqUrl.hash + "\n"; res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end(text); }).listen(3000, '127.0.0.1');QQ五笔截图未命名.png