김윤지

Merge branch 'master' into 'master'

데이터 전송 안되는것 수정, 그래프 추가

데이터 전송 안되는것 수정, 그래프 추가

See merge request !8
......@@ -39,6 +39,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
keys/
# TypeScript v1 declaration files
typings/
......
module.exports = {
key: "aaaa"
}
//개인 Server Key 받아서 사용해야함, Browser key 안됨
\ No newline at end of file
module.exports = {
key: "aaaa"
}
module.exports = {
host: 'localhost',
user: 'root',
password: 'Serrmica0!',
database: 'db_option_total'
}
\ No newline at end of file
......@@ -4,8 +4,8 @@ const secret_key_traffic = require('../keys/api_option_traffic').key;
const requesting = require('request');
const lat = "37.54922931758";//"37.239795"; //weather 위도
const lon = "126.913415969472";//"127.083240"; //weather 경도
const lat = "37.54922931758"; //weather 위도
const lon = "126.913415969472"; //weather 경도
const sido_num = "11"; //traffic 법정동 시도 코드
const gugun_num = "440"; //traffic 법정동 시군구 코드 - 합정동 일대
const search_year = "2018074"; //traffic 검색을 원하는 연도
......@@ -42,17 +42,18 @@ module.exports = (server, app) => {
json: true
},
//api에게 응답 받았을때 실행되는 callback function
function (err, api_res, api_body) {
function (err1, api_res1, api_body1) {
//err 존재시 promise reject 호출
if (err) reject(err);
if (err1) reject(err1);
// api의 response이 있을경우 promise resolve 호출
if (api_res) {
if (api_res1) {
console.log("calling weather api");
resolve(api_body);
resolve(api_body1);
}
});
})
}) //Promise
}
......@@ -63,12 +64,6 @@ module.exports = (server, app) => {
requesting.get({
// api를 요청할 주소 -- 시크릿키,위도,경도 입력
url: `http://apis.data.go.kr/B552061/${cate1}/${cate2}?ServiceKey=${secret_key_traffic}&searchYearCd=${search_year}&siDo=${sido_num}&guGun=${gugun_num}&type=json&numOfRows=1&pageNo=1`,
//나중에 삭제 http://apis.data.go.kr/B552061/frequentzoneLg/getRestFrequentzoneLg?ServiceKey=XOLqI9tY4gVCdk1i2BoOM3EYmSUYqt8WlXUfIDSfD4RnNBrFwwthbNAtGOxoskP540JbUAzcnuABsydoE2U2dA%3D%3D&searchYearCd=2017&siDo=11&guGun=200&type=json&numOfRows=10&pageNo=1
//나중에 삭제 http://apis.data.go.kr/B552061/frequentzoneLg/getRestFrequentzoneLg?ServiceKey=XOLqI9tY4gVCdk1i2BoOM3EYmSUYqt8WlXUfIDSfD4RnNBrFwwthbNAtGOxoskP540JbUAzcnuABsydoE2U2dA%3D%3D&searchYearCd=2018074&siDo=11&guGun=440&type=json&numOfRows=10&pageNo=1
//sido = 11 gugun = 440 (마포구 합정동, 도화동, 도화동)
//cate1 = frequentzoneLg
//cate2 = getRestFrequentzoneLg
//xml: true
json: true
},
//api에게 응답 받았을때 실행되는 callback function
......@@ -82,20 +77,26 @@ module.exports = (server, app) => {
resolve(api_body);
}
});
})
}) //Promise
}
const API_bundle = async () => {
try {
var order = 0;
while (order < 2) {
switch (order) {
case 0:
console.log("APIWait - WAITING FOR ALL API");
Current_Weather = await req_API("current", "minutely"); //현재날씨 (분별) //when, what
Sensible_T = await req_API("index", "wct"); //체감온도
Heat_index = await req_API("index", "heat"); //열지수
Discomport_index = await req_API("index", "th"); //불쾌지수
Ultra_Violet_index = await req_API("index", "uv"); //자외선지수
Current_TrafficAcc = await req_API_traffic("frequentzoneLg", "getRestFrequentzoneLg"); //cate1, cate2
order = 1;
break;
case 1:
console.log("APIDataProcess - CALLING INFO");
info = {
heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수
sensible_temperature: Sensible_T.weather.wIndex.wctIndex[0].current.index, //체감온도
......@@ -180,6 +181,13 @@ module.exports = (server, app) => {
db_total.query(sql, [client_send.time, client_send.wind, client_send.temperature, client_send.rain, client_send.death, client_send.trafficdeath, client_send.mhurt, client_send.lhurt, client_send.occurence], (err, result) => {
if (err) console.log(err);
})
order = 2;
break;
default:
order = 3;
break;
}//switch
}; //while
} catch (err) { //promise err or try err catch
console.log("================Error Occured !!================\n", err);
......
......@@ -4,7 +4,7 @@ var db = require('../lib/db_total');
/* GET home page. */
router.post('/starting' , (req,res) => {
router.post('/starting', (req, res) => {
res.redirect(`/name/${req.body.name}/birth/${req.body.birth}`);
})
router.get('/name/:name/birth/:birth', (req, res) => {
......@@ -23,10 +23,10 @@ router.get('/name/:name/birth/:birth', (req, res) => {
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();
var tdeathArr = new Array(); //사망자수
var mhurtArr = new Array(); //중상자수
var lhurtArr = new Array(); //경상자수
var occurArr = new Array(); //총 발생수
////////////////////////////////////////
......@@ -48,7 +48,7 @@ router.get('/name/:name/birth/:birth', (req, res) => {
wsArr.unshift(rows[i].wind);
rainArr.unshift(rows[i].rain);
////
deathArr.unshift(rows[i].tdeath);
tdeathArr.unshift(rows[i].tdeath);
mhurtArr.unshift(rows[i].mhurt);
lhurtArr.unshift(rows[i].lhurt);
occurArr.unshift(rows[i].occurence);
......@@ -71,7 +71,7 @@ router.get('/name/:name/birth/:birth', (req, res) => {
dataLen,
name,
birth,
deathArr,
tdeathArr,
mhurtArr,
lhurtArr,
occurArr
......
This diff is collapsed. Click to expand it.
<!DOCTYPE <!DOCTYPE html>
<!DOCTYPE
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
......@@ -9,7 +11,7 @@
<!-- font -->
<link href="https://fonts.googleapis.com/css?family=Nanum+Brush+Script&amp;subset=korean" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Yeon+Sung&amp;subset=korean" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Do+Hyeon&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="main.js"></script>
......@@ -42,13 +44,14 @@
h1 {
color: white;
font-family: 'Nanum Brush Script', cursive;
font-family: 'Do Hyeon', sans-serif;
//font-family: 'Nanum Brush Script', cursive;
}
label {
color: white;
font-size: 20px;
font-family: 'Yeon Sung', cursive;
font-family: 'Do Hyeon', sans-serif;
}
#banner {
......@@ -63,37 +66,41 @@
width: 100%;
height: 50px;
text-align: center;
font-family: 'Yeon Sung', cursive;
font-family: 'Do Hyeon', sans-serif;
color: white;
}
</style>
</head>
</head>
<body>
<img src="images/background.jpg" alt="" style="z-index:-1; min-width: 100%; min-height: 100%">
<body>
<img src="images/newbackground.png" alt="" style="z-index:-1; min-width: 100%; min-height: 100%">
<div id="banner">
<div style="width:100%; text-align: center; padding-top:170px;">
<h1 style="font-size:90px;">당신이 지금 죽을 확률은?</h1>
</div>
<br><br><br>
<br>
<br>
<br>
<div style="width:100%; text-align: center;">
<form action="/starting" method="post">
<div class="form-inline">
<label>이름</label>
<input type="text" name="name" class="form-control" placeholder="김철수" style="width:200px;">
<input type="text" name="name" class="form-control" placeholder="조인화" style="width:200px;">
&nbsp &nbsp&nbsp&nbsp
<label>생년월일</label>
<input type="text" name="birth" class="form-control" placeholder="971009" style="width:200px;">
<br><br><br>
<input type="submit" value="시작하기" class="btn btn-default" style="font-family: 'Yeon Sung', cursive; width:100px;font-weight: bold; font-size: 18px; background-color: white;">
<input type="text" name="birth" class="form-control" placeholder="991025" style="width:200px;">
<br>
<br>
<br>
<input type="submit" value="시작하기" class="btn btn-default" style="font-family: 'Do Hyeon', sans-serif; width:100px;font-weight: bold; font-size: 18px; background-color: white;">
</div>
</form>
</div>
</div>
<div id="footer">오픈소스SW개발 조민지 강환석 배희수</div>
</body>
<div id="footer">오픈소스SW개발 김주희 김윤지 조인화</div>
</body>
</html>
\ No newline at end of file
......