diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/china.sql" "b/\345\200\252\345\273\272\350\261\252/20220320/china.sql" new file mode 100644 index 0000000000000000000000000000000000000000..fc9f339768af11579a789e73b6d05a89d0ac3f72 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/china.sql" @@ -0,0 +1 @@ +SELECT * FROM yiqing.new_table; \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/dynmic.js" "b/\345\200\252\345\273\272\350\261\252/20220320/dynmic.js" new file mode 100644 index 0000000000000000000000000000000000000000..42bf9f01db0d48aea1c5b7340e0d57308efb960a --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/dynmic.js" @@ -0,0 +1,53 @@ +let http=require('http'); +let fs=require('fs'); +let nunjucks=require('nunjucks'); +http.createServer(async(req,res)=>{ + let url= req.url; + console.log(url); + if (url.lastIndexOf('.')>-1) { + let path='.'+url; + console.log(path); + fs.exists(path,(result)=>{ + if (!result) { + path='./home/img/404.png' + // res.end() + } + fs.readFile(path,(err,data)=>{ + if (err) { + console.log(err); + } else { + res.write(data); + res.end() + } + }) + }) + } else { + // res.setHeader("Content-type", "text/html;charset=utf8"); + // res.setHeader("Content-type", "text/css;charset=utf8"); + let url=req.url; + let query=url.split('?')[1]; + let queryArr=query.split('&'); + let needArr=[]; + for (let values of queryArr) { + let tempArr=values.split('='); + needArr[tempArr[0]]=tempArr[1]; + } + // console.log(needArr); + req.query=needArr; + // console.log(req.query); + let controllerName=needArr['c']; + let path='./home/controller/'+controllerName; + console.log("path:"+path); + let controller=require(path); + console.log("path:"+path); + let action=needArr['a']; + let obj=new controller(req,res,nunjucks); + let result=await obj[action](); + console.log(result); + res.write(result); + res.end() + + + } + +}).listen(8080) diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/controller/baseController.js" "b/\345\200\252\345\273\272\350\261\252/20220320/home/controller/baseController.js" new file mode 100644 index 0000000000000000000000000000000000000000..9a070340c1fa9d41f57b9560c32908dbaae3a918 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/home/controller/baseController.js" @@ -0,0 +1,12 @@ +class baseController{ + constructor(req,res,nunjucks){ + this.req=req; + this.res=res; + this.nunjucks=nunjucks; + this.nunjucks.configure('./home/html',{autoescape:true}); + } + display(path,data){ + return this.nunjucks.render(path,data) + } +} +module.exports=baseController; \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/controller/index.js" "b/\345\200\252\345\273\272\350\261\252/20220320/home/controller/index.js" new file mode 100644 index 0000000000000000000000000000000000000000..c88c4986a8a94546749b139ddc97f067ff7fb3b3 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/home/controller/index.js" @@ -0,0 +1,19 @@ +const Base=require('../../model/Base'); +const baseController=require('./baseController'); +class index extends baseController{ + async index(){ + let model=new Base(); + let sql="select * from china where region=?" + let region=this.req.query['region']?this.req.query['region']:'泉州'; + let data=await model.query(sql,region); + console.log("data"+data['region']); + return this.display('index.html',{key:data,title:'疫情实时速报'}) + } + async select(){ + let model=new Base(); + let sql="select * from china" + let data=await model.query(sql); + return this.display('index.html',{key:data,title:'疫情实时速报'}) + } +} +module.exports=index; \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/css/style.css" "b/\345\200\252\345\273\272\350\261\252/20220320/home/css/style.css" new file mode 100644 index 0000000000000000000000000000000000000000..32998f52dd7f460d1928778b659601ccdd3c7497 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/home/css/style.css" @@ -0,0 +1,141 @@ + +*{ + margin: 0; + padding: 0; + font-size: 16px; +} +body{ + background-color: #10aed5; + position: relative; +} +#yq_top{ + width: 768px; + background: url(../img/bd.png); + background-position: 50% 50%; + /* position: absolute; */ + right: 0; + left: 0; + margin: auto; + background-repeat: no-repeat; + background-size: 695px 189px; + height: 187px; +} +h1{ + color: white; + font-size: 2rem; + height: 2rem; + line-height: 2rem; + margin-top: 10px; + margin-left: 1rem; +} +h3{ + color: #c4faff; + margin-left: 1rem; +} +.yq_liulang{ + /* width: auto; */ + display: inline-block; + margin-left: 1rem; + color: #c4faff; + margin-top: 10px; + padding: 0 0.6rem; + border-radius: 0.7rem; + font-size: 0.68rem; + background-color: rgba(9, 148, 167, 5); +} +#yq_1{ + position: relative; + border-radius: 1rem; + right: 0; + left: 0; + /* top: 1.5rem; */ + margin: auto; + background-color: white; + height: 1024px; + width: 768px; + +} +.yq_miaoshu,h2{ + /* position: absolute; */ + width: 96%; + right: 0; + left: 0; + margin: auto; +} +.yq_title::before{ + content: ""; + background: url(../img/feiji.png); + width: 1rem; + height: 1rem; + display: inline-block; + background-repeat: no-repeat; + background-size: 1rem 1rem; + margin-right: 0.3rem; + +} +#yq_shuju_1{ + width: 96%; + position: absolute; + right: 0; + left: 0; + margin: auto; + /* display: flex; + flex-direction: row; */ +} +.yq_liebiao_a{ + width: 100%; + display: flex; + position: relative; + /* justify-content: center; */ +} +.yq_liebiao_a .yq_liebiao_1{ + width: 50%; + height: 32px; + background-color: #eee; + /* text-align: center; */ + padding-left: 10px; + line-height: 32px; +} +.yq_liebiao_a .yq_liebiao_2{ + width: 25%; + height: 32px; + background-color: #eee; + text-align: center; + line-height: 32px; +} + +.yq_liebiao_b{ + width: 100%; + display: flex; + position: relative; +} +.yq_liebiao_b::after{ + content: ""; + position: absolute; + bottom: 0; + left: 0; + height: 2px; + width: 100%; + background-color:#eee ; + +} + +.yq_liebiao_b .yq_liebiao_1{ + width: 50%; + height: 32px; + background-color: white; + /* text-align: center; */ + padding-left: 10px; + line-height: 32px; + color: rgb(39, 114, 89); +} +.yq_liebiao_b .yq_liebiao_2{ + width: 25%; + height: 32px; + background-color: white; + text-align: center; + line-height: 32px; +} +.yq_liebiao_b .yq_liebiao_color{ + color: rgb(41, 138, 230); +} \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/html/index.html" "b/\345\200\252\345\273\272\350\261\252/20220320/home/html/index.html" new file mode 100644 index 0000000000000000000000000000000000000000..789bcf10d17ee39a35a4aa19a187326309cfd195 --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/home/html/index.html" @@ -0,0 +1,48 @@ + + +
+ + + +