김주희

Merge branch 'design' to 'master'

var express = require('express');
var router = express.Router();
var db = require('../lib/db');
var db = require('../lib/db_total');
/* GET home page. */
router.post('/starting' , (req,res) => {
res.redirect(`/name/${req.body.name}/birth/${req.body.birth}`);
res.redirect(`/name/${req.body.name}/birth/${req.body.birth}`);
})
router.get('/name/:name/birth/:birth', (req,res) => {
// 렌더링 변수
var time = new Array(); // 타임스탬프
var ptArr = new Array(); // 현재 온도
var wsArr = new Array(); // 풍속
var rainArr = new Array(); // 강우량
var probArr = new Array(); // 사망 확률
var dataLen = 0; // 데이터 개수
var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var sql = ""; // 쿼리
var count = 0;
const name = req.params.name;
const birth = req.params.birth;
router.get('/name/:name/birth/:birth', (req, res) => {
// 이전 10분간 데이터 찾기
sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -20 MINUTE), '%Y-%m-%d %H:%i:%s')";
db.query(sql, function(err, rows, fields){
if(err)
{
console.log(err);
}
else
{
if (rows.length == 0)
{
empty = 1;
}
else
{
for(var i = rows.length - 1; i >= 0; i--)
{
probArr.unshift(rows[i].prob);
time.unshift(rows[i].time);
ptArr.unshift(rows[i].temperature);
wsArr.unshift(rows[i].wind);
rainArr.unshift(rows[i].rain);
count = count + 1;
// 렌더링 변수
var time = new Array(); // 타임스탬프
var ptArr = new Array(); // 현재 온도
var wsArr = new Array(); // 풍속
var rainArr = new Array(); // 강우량
var probArr = new Array(); // 사망 확률
var dataLen = 0; // 데이터 개수
var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var sql = ""; // 쿼리
var count = 0;
const name = req.params.name;
const birth = req.params.birth;
//const address = req.params.address;
////////////////////////////////////////
var deathArr = new Array();
var mhurtArr = new Array();
var lhurtArr = new Array();
var occurArr = new Array();
////////////////////////////////////////
if (count == 10){
break;
}
// 이전 10분간 데이터 찾기
sql = "SELECT * FROM apisInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -20 MINUTE), '%Y-%m-%d %H:%i:%s')";
db.query(sql, function (err, rows, fields) {
if (err) {
console.log(err);
}
}
else {
if (rows.length == 0) {
empty = 1;
}
else {
for (var i = rows.length - 1; i >= 0; i--) {
probArr.unshift(rows[i].prob);
time.unshift(rows[i].time);
ptArr.unshift(rows[i].temperature);
wsArr.unshift(rows[i].wind);
rainArr.unshift(rows[i].rain);
////
deathArr.unshift(rows[i].tdeath);
mhurtArr.unshift(rows[i].mhurt);
lhurtArr.unshift(rows[i].lhurt);
occurArr.unshift(rows[i].occurence);
count = count + 1;
if (count == 10) {
break;
}
}
}
dataLen = probArr.length;
res.render('index', {
empty,
time,
ptArr,
wsArr,
rainArr,
probArr,
dataLen,
name,
birth
});
}
});
} )
router.get('/', function(req, res, next) {
res.render( 'main' );
dataLen = probArr.length;
res.render('index', {
empty,
time,
ptArr,
wsArr,
rainArr,
probArr,
dataLen,
name,
birth,
deathArr,
mhurtArr,
lhurtArr,
occurArr
});
}
});
})
router.get('/', function (req, res, next) {
res.render('main');
});
module.exports = router;
......
This diff is collapsed. Click to expand it.
<!-- <!DOCTYPE html>
<html>
<head>
<!-- font -->
<link href="https://fonts.googleapis.com/css?family=Nanum+Brush+Script&amp;subset=korean" rel="stylesheet" />
......@@ -39,7 +38,7 @@
<script src="modules/exporting.js"></script>
<script src="modules/export-data.js"></script>
<img src="images/background.jpg" alt="" style="z-index:-1; min-width: 100%; min-height: 100%">
<img src="images/newbackground.png" alt="" style="z-index:-1; min-width: 100%; min-height: 100%">
<div id="banner">
<div id="container1" style="width:1260px; height: 400px; margin: 0 auto;"></div>
......
......@@ -24,48 +24,48 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<style type="text/css">
html,
{
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
/* background-image: url('background.jpg');
background-repeat: no-repeat;
background-size: cover; */
/* background: linear-gradient( to bottom, #fbc2eb, #a6c1ee ); */
}
h1 {
color: white;
font-family: 'Nanum Brush Script', cursive;
}
label {
color: white;
font-size: 20px;
font-family: 'Yeon Sung', cursive;
}
#banner {
position: absolute;
top: 0;
width: 100%;
}
#footer {
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
font-family: 'Yeon Sung', cursive;
color: white;
}
html,
{
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
/* background-image: url('newbackground.png');
background-repeat: no-repeat;
background-size: cover; */
/* background: linear-gradient( to bottom, #fbc2eb, #a6c1ee ); */
}
h1 {
color: white;
font-family: 'Nanum Brush Script', cursive;
}
label {
color: white;
font-size: 20px;
font-family: 'Yeon Sung', cursive;
}
#banner {
position: absolute;
top: 0;
width: 100%;
}
#footer {
position: absolute;
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
font-family: 'Yeon Sung', cursive;
color: white;
}
</style>
</head>
......
......@@ -21,7 +21,7 @@
/* background: linear-gradient( to bottom, #65799B, rgb(38, 14, 41) ); */
/* background-color:#65799B; */
/* background-image: url("2.jpg");
/* background-image: url("newbackground.png");
background-repeat: no-repeat;
background-size: cover; */
}
......@@ -38,7 +38,7 @@
<script src="highcharts.js"></script>
<script src="modules/exporting.js"></script>
<script src="modules/export-data.js"></script>
<img src="images/background.jpg" alt="" style="z-index:-1; min-width: 100%; min-height: 100%">
<img src="images/newbackground.png" alt="" style="z-index:-1; min-width: 100%; min-height: 100%">
<div id="banner">
<div id="container1" style="width:1260px; height: 400px; margin: 0 auto"></div>
......