Suyeon Jung

Complete safe category

......@@ -293,6 +293,52 @@ router.get('/park', function(req, res) {
})
});
router.get('/transport', function(req, res) {
res.send(BusCnt);
});
router.get('/safe', function(req, res) {
let cctv_url = 'https://openapi.gg.go.kr/CCTV';
let light_url = 'https://openapi.gg.go.kr/SECRTLGT'
let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}`;
request({
url: cctv_url + qs,
method: 'GET'
}, function(err, response, body) {
if (!err && res.statusCode == 200) {
let cctv_result = JSON.parse(body);
let cctvs = [];
console.log(cctv_result);
for (let i = 0; i < cctv_result.CCTV[1].row.length; i++) {
cctv = cctv_result.CCTV[1].row[i];
console.log('cctv', cctv);
cctvs.push(cctv);
}
request({
url: light_url + qs,
method: 'GET'
}, function(err, response, body) {
if (!err && res.statusCode == 200) {
let light_result = JSON.parse(body);
let lights = [];
console.log(light_result);
for (let i = 0; i < light_result.SECRTLGT[1].row.length; i++) {
light = light_result.SECRTLGT[1].row[i];
console.log('light', light);
lights.push(light);
}
res.render('safe_result', { cctvs: cctvs, lights: lights });
}
})
}
})
});
router.get('/culture', function(req, res) {
res.send('This is culture');
});
router.get('/shop', function(req, res) {
let mallnum = 0;
......@@ -312,7 +358,6 @@ router.get('/shop', function(req, res) {
shops.push(shop);
}
res.render('shop_result', { shops: shops });
}
// var shop_result = JSON.parse(body);
// if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') {
......@@ -356,15 +401,6 @@ router.get('/gym', function(req, res) {
// }
})
});
router.get('/transport', function(req, res) {
res.send(BusCnt);
});
router.get('/safe', function(req, res) {
res.send('This is safe');
});
router.get('/culture', function(req, res) {
res.send('This is culture');
});
module.exports = router;
\ No newline at end of file
......
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>✍️ 결과 페이지</title>
</head>
<body>
<h1>📷 CCTV 현황</h1>
CCTV 소재지 지번주소 :
<%for (var i =0; i <cctvs.length; i++){%>
<li>
<%=cctvs[i].REFINE_LOTNO_ADDR%>
</li>
<%}%>
<h3>총 CCTV 개수 :
<%=cctvs.length%>
</h3>
<h1>💡 보안등 현황</h1>
보안등 소재지 지번주소 :
<%for (var i =0; i <lights.length; i++){%>
<li>
<%=lights[i].REFINE_LOTNO_ADDR%>
</li>
<%}%>
<h3>총 보안등 개수 :
<%=lights.length%>
</h3>
</body>
</html>
\ No newline at end of file