diff --git "a/\345\220\264\351\246\231\350\220\215/0303/fsdome.js" "b/\345\220\264\351\246\231\350\220\215/0303/fsdome.js" new file mode 100644 index 0000000000000000000000000000000000000000..84a20a1b5d258b957f9620403fc99ed9b0639e62 --- /dev/null +++ "b/\345\220\264\351\246\231\350\220\215/0303/fsdome.js" @@ -0,0 +1,16 @@ +let http = require('http'); + +let server = http.createServer(); +server.on('request',(req,res)=>{ + res.setHeader("Content-Type", "text/html; charset=utf-8") + res.write("Hello") + if(req.url == '/?intex.html'){ + res.write("进入成功") + } + if(req.url == '/?intex1.html'){ + res.write("进入第二个页面") + } + + res.end(); +}) +server.listen(8080); \ No newline at end of file diff --git "a/\345\220\264\351\246\231\350\220\215/0304/css/2.css" "b/\345\220\264\351\246\231\350\220\215/0304/css/2.css" new file mode 100644 index 0000000000000000000000000000000000000000..ab8dcfb408b5a7d0a47b1714add452f70d44eedf --- /dev/null +++ "b/\345\220\264\351\246\231\350\220\215/0304/css/2.css" @@ -0,0 +1,4 @@ + +*{ + background-color: antiquewhite; +} \ No newline at end of file diff --git "a/\345\220\264\351\246\231\350\220\215/0304/fshtp.js" "b/\345\220\264\351\246\231\350\220\215/0304/fshtp.js" new file mode 100644 index 0000000000000000000000000000000000000000..a2492be055a7c6505917d3ba3fc3c2f101ecb0aa --- /dev/null +++ "b/\345\220\264\351\246\231\350\220\215/0304/fshtp.js" @@ -0,0 +1,25 @@ +//优化 http 处理不同静态文件 css js image,放在不同的目录 css 放于 css 目录下 js放于 js 目录下,image 放于 image 下 + +let http = require('http'); +let fs = require('fs'); +let server =http.createServer(); + +server.on('request',(req,res) => { + res.setHeader('Content-type','text/html; charset=utf-8'); + console.log(req.url); + if(req.url === '/html'){ + res.write(fs.readFileSync('./html/1.html')) + } + if(req.url === '/css'){ + res.writeHead(200, { 'Content-Type': 'text/css' }); + res.write(fs.readFileSync('./css/2.css')) + } + if(req.url === '/img'){ + res.writeHead(200, {'Content-Type': 'image/jpg'}); + res.write(fs.readFileSync('./img/ui.jpg')) + } + + + res.end(); +}) +server.listen(8080); \ No newline at end of file diff --git "a/\345\220\264\351\246\231\350\220\215/0304/html/1.html" "b/\345\220\264\351\246\231\350\220\215/0304/html/1.html" new file mode 100644 index 0000000000000000000000000000000000000000..2a1dca947dcfb2537ce01f072aa53a3f7d2f825f --- /dev/null +++ "b/\345\220\264\351\246\231\350\220\215/0304/html/1.html" @@ -0,0 +1,15 @@ + + + + + + + Document + + + +

开启

+
+

成功

+ + \ No newline at end of file diff --git "a/\345\220\264\351\246\231\350\220\215/0304/img/ui.jpg" "b/\345\220\264\351\246\231\350\220\215/0304/img/ui.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..9c7483fd89370f23893a0d07f0f8df03c896fd9c Binary files /dev/null and "b/\345\220\264\351\246\231\350\220\215/0304/img/ui.jpg" differ