diff --git "a/\345\200\252\345\273\272\350\261\252/211210_CSS\344\275\234\344\270\232_CSS\346\212\200\345\267\247_\346\214\211\351\222\256/btn.html" "b/\345\200\252\345\273\272\350\261\252/211210_CSS\344\275\234\344\270\232_CSS\346\212\200\345\267\247_\346\214\211\351\222\256/btn.html" new file mode 100644 index 0000000000000000000000000000000000000000..b8b017e75729c74833dc7ffa78be6aa665b3ad9d --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/211210_CSS\344\275\234\344\270\232_CSS\346\212\200\345\267\247_\346\214\211\351\222\256/btn.html" @@ -0,0 +1,89 @@ + + + + + + Document + + + +
+ + + + + + +
+ + + \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/a.txt" "b/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/a.txt" new file mode 100644 index 0000000000000000000000000000000000000000..7b35aab95ff81a6ae61d7f01bbca8d961b174777 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/a.txt" @@ -0,0 +1 @@ +再次写入新信息 \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/file_sever.js" "b/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/file_sever.js" new file mode 100644 index 0000000000000000000000000000000000000000..741f7e732d9beeb293e2e4d03b4712ab2ad88025 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/file_sever.js" @@ -0,0 +1,42 @@ +let fs=require("fs"); +let http=require("http"); +let url=require("url"); +let path=require("path"); + +//命令行参数获取root目录,默认是当前目录 +let root=path.resolve('.'); +//输出根目录的路径 +console.log("根目录路径"+root) + +//创建服务器 +let sever=http.createServer(function(request,response){ + let pathname=url.parse(request.url).pathname +// let wrorDir=path.resolve('.'); + let filepath=path.join(root,pathname); + + + //获取文件的状态 + fs.stat(filepath,function(err,stats){ + if(!err && stats.isFile()){ + //没有出错并且文件存在 + console.log('200'+request.url); + //发送200,表示请求成功 + response.writeHead(200); + fs.createReadStream(filepath).pipe(response) + }else{ + // console.log("404"+request.url); + // response.writeHead(404); + // // fs.createReadStream(filepath).pipe(response) + // response.end("404 End Found") + //没有出错并且文件存在 + console.log('200'+request.url); + //发送200,表示请求成功 + response.writeHead(200); + let filepath=path.join(root,pathname,"index.html") + fs.createReadStream(filepath).pipe(response) + + } + }) +}).listen(8080,function(){ + console.log('服务启动,访问地址:http://127.0.0.1:8080'); +}) \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/index.html" "b/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/index.html" new file mode 100644 index 0000000000000000000000000000000000000000..276bb624b27acfe2b5c78f4dc726a19cb766e0ea --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/index.html" @@ -0,0 +1,21 @@ + + + + + + + Document + + + +
+ +
+ + \ No newline at end of file