From eb79631e958382957b51c37d867106217759186e Mon Sep 17 00:00:00 2001 From: nijianhao654 <2197024383@qq.com> Date: Mon, 13 Dec 2021 17:39:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?12=E6=9C=8810=E6=97=A5=20CSS=E6=8A=80?= =?UTF-8?q?=E5=B7=A7=5F=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../btn.html" | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 "\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" 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 0000000..b8b017e --- /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 -- Gitee From b5f80a05cbd5165cef4789066671a6438a1ddc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=AA=E5=BB=BA=E8=B1=AA?= <2197024383@qq.com> Date: Sun, 19 Dec 2021 21:26:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?12=E6=9C=8817=E6=97=A5MVC=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../211217-MVC\344\275\234\344\270\232/a.txt" | 1 + .../file_sever.js" | 42 +++++++++++++++++++ .../index.html" | 21 ++++++++++ 3 files changed, 64 insertions(+) create mode 100644 "\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/a.txt" create mode 100644 "\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/file_sever.js" create mode 100644 "\345\200\252\345\273\272\350\261\252/211217-MVC\344\275\234\344\270\232/index.html" 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 0000000..7b35aab --- /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 0000000..741f7e7 --- /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 0000000..276bb62 --- /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 -- Gitee