Suyeon Jung

Complete safe category

...@@ -293,6 +293,52 @@ router.get('/park', function(req, res) { ...@@ -293,6 +293,52 @@ router.get('/park', function(req, res) {
293 }) 293 })
294 }); 294 });
295 295
296 +router.get('/transport', function(req, res) {
297 + res.send(BusCnt);
298 +});
299 +router.get('/safe', function(req, res) {
300 +
301 + let cctv_url = 'https://openapi.gg.go.kr/CCTV';
302 + let light_url = 'https://openapi.gg.go.kr/SECRTLGT'
303 + let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}`;
304 + request({
305 + url: cctv_url + qs,
306 + method: 'GET'
307 + }, function(err, response, body) {
308 + if (!err && res.statusCode == 200) {
309 + let cctv_result = JSON.parse(body);
310 + let cctvs = [];
311 + console.log(cctv_result);
312 + for (let i = 0; i < cctv_result.CCTV[1].row.length; i++) {
313 + cctv = cctv_result.CCTV[1].row[i];
314 + console.log('cctv', cctv);
315 + cctvs.push(cctv);
316 + }
317 + request({
318 + url: light_url + qs,
319 + method: 'GET'
320 + }, function(err, response, body) {
321 + if (!err && res.statusCode == 200) {
322 + let light_result = JSON.parse(body);
323 + let lights = [];
324 + console.log(light_result);
325 + for (let i = 0; i < light_result.SECRTLGT[1].row.length; i++) {
326 + light = light_result.SECRTLGT[1].row[i];
327 + console.log('light', light);
328 + lights.push(light);
329 + }
330 + res.render('safe_result', { cctvs: cctvs, lights: lights });
331 + }
332 + })
333 + }
334 +
335 + })
336 +});
337 +
338 +router.get('/culture', function(req, res) {
339 + res.send('This is culture');
340 +});
341 +
296 router.get('/shop', function(req, res) { 342 router.get('/shop', function(req, res) {
297 343
298 let mallnum = 0; 344 let mallnum = 0;
...@@ -312,7 +358,6 @@ router.get('/shop', function(req, res) { ...@@ -312,7 +358,6 @@ router.get('/shop', function(req, res) {
312 shops.push(shop); 358 shops.push(shop);
313 } 359 }
314 res.render('shop_result', { shops: shops }); 360 res.render('shop_result', { shops: shops });
315 -
316 } 361 }
317 // var shop_result = JSON.parse(body); 362 // var shop_result = JSON.parse(body);
318 // if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') { 363 // if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') {
...@@ -356,15 +401,6 @@ router.get('/gym', function(req, res) { ...@@ -356,15 +401,6 @@ router.get('/gym', function(req, res) {
356 // } 401 // }
357 }) 402 })
358 }); 403 });
359 -router.get('/transport', function(req, res) {
360 - res.send(BusCnt);
361 -});
362 -router.get('/safe', function(req, res) {
363 - res.send('This is safe');
364 -});
365 404
366 -router.get('/culture', function(req, res) {
367 - res.send('This is culture');
368 -});
369 405
370 module.exports = router; 406 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
1 +<!DOCTYPE html>
2 +<html lang="ko">
3 +
4 +<head>
5 + <meta charset="UTF-8">
6 + <title>✍️ 결과 페이지</title>
7 +</head>
8 +
9 +<body>
10 + <h1>📷 CCTV 현황</h1>
11 + CCTV 소재지 지번주소 :
12 + <%for (var i =0; i <cctvs.length; i++){%>
13 + <li>
14 + <%=cctvs[i].REFINE_LOTNO_ADDR%>
15 + </li>
16 +
17 + <%}%>
18 + <h3>총 CCTV 개수 :
19 + <%=cctvs.length%>
20 + </h3>
21 + <h1>💡 보안등 현황</h1>
22 + 보안등 소재지 지번주소 :
23 + <%for (var i =0; i <lights.length; i++){%>
24 + <li>
25 + <%=lights[i].REFINE_LOTNO_ADDR%>
26 + </li>
27 +
28 + <%}%>
29 + <h3>총 보안등 개수 :
30 + <%=lights.length%>
31 + </h3>
32 +
33 +</body>
34 +
35 +</html>
...\ No newline at end of file ...\ No newline at end of file