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 @@ + + + + + + + 疫情实时大数据报告 + + + + +
+

新型冠状病毒肺炎

+

疫情实时大数据报告

+
共10472902151人次已浏览
+
+
+

{{title}}

+
该数据为31省新增确诊数据
+
+
+
地区
+
新增本土
+
现有确诊
+
+ +
+
香港
+
1860
+
236227
+
+ + + {% for item in key %} +
+
{{item.region}}
+
{{item.add}}
+
{{item.existing}}
+
+ {% endfor %} + + + + +
+
+ + \ No newline at end of file diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/img/404.png" "b/\345\200\252\345\273\272\350\261\252/20220320/home/img/404.png" new file mode 100644 index 0000000000000000000000000000000000000000..4f7a49c44607c21df160f6bc941704c46c6c320a Binary files /dev/null and "b/\345\200\252\345\273\272\350\261\252/20220320/home/img/404.png" differ diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/img/bd.png" "b/\345\200\252\345\273\272\350\261\252/20220320/home/img/bd.png" new file mode 100644 index 0000000000000000000000000000000000000000..dfa9596daf9caa232aaeb6aaf4ee6e40cb07bba3 Binary files /dev/null and "b/\345\200\252\345\273\272\350\261\252/20220320/home/img/bd.png" differ diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/home/img/feiji.png" "b/\345\200\252\345\273\272\350\261\252/20220320/home/img/feiji.png" new file mode 100644 index 0000000000000000000000000000000000000000..5206ca27788338b2890cb6068f49b8c173cc72fb Binary files /dev/null and "b/\345\200\252\345\273\272\350\261\252/20220320/home/img/feiji.png" differ diff --git "a/\345\200\252\345\273\272\350\261\252/20220320/model/Base.js" "b/\345\200\252\345\273\272\350\261\252/20220320/model/Base.js" new file mode 100644 index 0000000000000000000000000000000000000000..66bd1698120a578809a1f0aefae90d6d71af64ef --- /dev/null +++ "b/\345\200\252\345\273\272\350\261\252/20220320/model/Base.js" @@ -0,0 +1,36 @@ + +let mysql=require('mysql'); + +class Base{ + async query(sql,value){ + let promise=new Promise((resolve,rejects)=>{ + let connection=mysql.createConnection({ + host:'127.0.0.1', + user:'root', + password:'123456', + database:'yiqing', + port:'3306' + }); + + connection.connect(); + connection.query(sql,value,(err,result)=>{ + if (err) { + rejects(err.message) + }else{ + resolve(result) + } + }) + connection.end(); + + }) + + return promise; + } + select() { + + let sql = 'select * from ' + this.table; + return this.query(sql, '') + } + +} +module.exports=Base; \ No newline at end of file