```javascript
var http = require('http')
var url = require('url')
var fs = require('fs')
var querystring = require('querystring')
var app = http.createServer((req, res) => {
var urlParse = url.parse(req.url)
switch (urlParse.pathname) {
case '/':
readFi('home.html', res)
break;
case '/index.html':
readFi('index.html',res)
break;
case '/login.html':
readFi('login.html', res)
break;
case '/login/check':
var query = (querystring.parse(urlParse.query))
console.log(query)
res.writeHead(200, {
'content-type': 'text/html;charset=utf-8'
})
res.end('用户名是' + query.username + '密码' + query.password)
break;
default:
readFi('404.html', res)
break;
}
}).listen(8080, '127.0.0.1')
function readFi(file,res) {
fs.readFile(file, (err, data) => {
if (err) {
return console.log(err)
}
res.writeHead(200, {
'content-type': 'text/html;charset=utf-8'
})
res.end(data)
})
}