Suyeon Jung

Test result view

...@@ -8,14 +8,14 @@ let SIGUN_CODE; ...@@ -8,14 +8,14 @@ let SIGUN_CODE;
8 let SIGUNDONG_CODE; 8 let SIGUNDONG_CODE;
9 9
10 // 사용자가 index 페이지에서 주소를 입력하고 넘어오면 10 // 사용자가 index 페이지에서 주소를 입력하고 넘어오면
11 -router.post('/', function (req, res) { 11 +router.post('/', function(req, res) {
12 console.log(req.body); 12 console.log(req.body);
13 let userLocation = req.body.userLocation; 13 let userLocation = req.body.userLocation;
14 // let userSi = req.body.si 14 // let userSi = req.body.si
15 // let userDong = req.body.dong; 15 // let userDong = req.body.dong;
16 - let xyList = []; 16 + let user_latitude;
17 + let user_logitude;
17 console.log(userLocation); 18 console.log(userLocation);
18 - // console.log(req);
19 let KAKAO_API_KEY = process.env.KAKAO_APIKEY; 19 let KAKAO_API_KEY = process.env.KAKAO_APIKEY;
20 let kakaoOptions = { 20 let kakaoOptions = {
21 url: 'https://dapi.kakao.com/v2/local/search/address.json', 21 url: 'https://dapi.kakao.com/v2/local/search/address.json',
...@@ -28,67 +28,73 @@ router.post('/', function (req, res) { ...@@ -28,67 +28,73 @@ router.post('/', function (req, res) {
28 }, 28 },
29 encoding: 'UTF-8', 29 encoding: 'UTF-8',
30 } 30 }
31 - request(kakaoOptions, function (err, res, body) { 31 + request(kakaoOptions, function(err, res, body) {
32 if (!err && res.statusCode == 200) { 32 if (!err && res.statusCode == 200) {
33 var result = JSON.parse(body); 33 var result = JSON.parse(body);
34 console.log('result', result); 34 console.log('result', result);
35 - x = result.documents[0].address.x; 35 + user_latitude = result.documents[0].address.x;
36 - y = result.documents[0].address.y; 36 + user_logitude = result.documents[0].address.y;
37 - 37 + console.log(user_latitude, user_logitude);
38 -
39 } 38 }
40 }) 39 })
41 res.render('category', { userLocation: req.body.userLocation }); 40 res.render('category', { userLocation: req.body.userLocation });
42 }); 41 });
43 42
44 43
45 -router.get('/food', function (req, res) { 44 +router.get('/food', function(req, res) {
46 45
47 // 맛집 리스트 조회 46 // 맛집 리스트 조회
48 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; 47 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
49 let sigun_cd = 41110; 48 let sigun_cd = 41110;
50 let url = 'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt'; 49 let url = 'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt';
51 - let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`; 50 + let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}&Type=json`;
52 51
53 request({ 52 request({
54 url: url + qs, 53 url: url + qs,
55 method: 'GET' 54 method: 'GET'
56 - }, function (err, response, body) { 55 + }, function(err, response, body) {
57 if (!err && res.statusCode == 200) { 56 if (!err && res.statusCode == 200) {
58 - let re = body; 57 + let food_result = JSON.parse(body);
59 - console.log(body); 58 + let store_names = []
60 - res.send(re); 59 + // console.log('정상출력여부', result)
60 + // console.log('총 출력 개수', result.PlaceThatDoATasteyFoodSt[0].head[0].list_total_count);
61 + for (let i = 0; i < 16; i++) {
62 + // 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR)
63 + store_name = food_result.PlaceThatDoATasteyFoodSt[1].row[i];
64 + console.log('store_name', store_name);
65 + store_names.push(store_name);
66 + }
67 + console.log('food_result', food_result)
68 + res.render('result', { store_names: store_names });
61 } 69 }
62 }); 70 });
63 }); 71 });
64 -router.get('/school', function (req, res) { 72 +router.get('/school', function(req, res) {
65 res.send('This is school'); 73 res.send('This is school');
66 }); 74 });
67 -router.get('/park', function (req, res) { 75 +router.get('/park', function(req, res) {
68 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; 76 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
69 let sigun_cd = 41110; 77 let sigun_cd = 41110;
70 let cityparknum = 0; 78 let cityparknum = 0;
71 let url = 'https://openapi.gg.go.kr/CityPark'; 79 let url = 'https://openapi.gg.go.kr/CityPark';
72 let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`; 80 let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`;
73 request({ 81 request({
74 - url: url + qs, 82 + url: url + qs,
75 - method: 'GET' 83 + method: 'GET'
76 - }, function (err, response, body) { 84 + }, function(err, response, body) {
77 - var park_result = JSON.parse(body); 85 + var park_result = JSON.parse(body);
78 - if (park_result.CityPark[0].head[1].RESULT.CODE == 'INFO-000') { 86 + if (park_result.CityPark[0].head[1].RESULT.CODE == 'INFO-000') {
79 - cityparknum = park_result.CityPark[0].head[0].list_total_count; 87 + cityparknum = park_result.CityPark[0].head[0].list_total_count;
80 - console.log(cityparknum + "개의 도시공원이 존재합니다."); 88 + console.log(cityparknum + "개의 도시공원이 존재합니다.");
81 - res.send(String(cityparknum) + "개의 도시공원이 존재합니다."); 89 + res.send(String(cityparknum) + "개의 도시공원이 존재합니다.");
82 - } 90 + } else {
83 - else{ 91 + res.send("도시공원이 없습니다.");
84 - res.send("도시공원이 없습니다."); 92 + }
85 - } 93 + })
86 - } 94 + //res.send('This is park');
87 - )
88 - //res.send('This is park');
89 }); 95 });
90 96
91 -router.get('/shop', function (req, res) { 97 +router.get('/shop', function(req, res) {
92 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; 98 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
93 let sigun_cd = 41110; 99 let sigun_cd = 41110;
94 let mallnum = 0; 100 let mallnum = 0;
...@@ -97,21 +103,19 @@ router.get('/shop', function (req, res) { ...@@ -97,21 +103,19 @@ router.get('/shop', function (req, res) {
97 request({ 103 request({
98 url: url + qs, 104 url: url + qs,
99 method: 'GET' 105 method: 'GET'
100 - }, function (err, response, body) { 106 + }, function(err, response, body) {
101 var shop_result = JSON.parse(body); 107 var shop_result = JSON.parse(body);
102 if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') { 108 if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') {
103 mallnum = shop_result.MrktStoreM[0].head[0].list_total_count; 109 mallnum = shop_result.MrktStoreM[0].head[0].list_total_count;
104 console.log(mallnum + "개의 쇼핑몰이 존재합니다."); 110 console.log(mallnum + "개의 쇼핑몰이 존재합니다.");
105 res.send(String(mallnum) + "개의 쇼핑몰이 존재합니다."); 111 res.send(String(mallnum) + "개의 쇼핑몰이 존재합니다.");
106 - } 112 + } else {
107 - else{
108 res.send("쇼핑몰이 없습니다."); 113 res.send("쇼핑몰이 없습니다.");
109 } 114 }
110 - } 115 + })
111 - )
112 }); 116 });
113 117
114 -router.get('/gym', function (req, res) { 118 +router.get('/gym', function(req, res) {
115 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; 119 let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
116 let sigun_cd = 41110; 120 let sigun_cd = 41110;
117 let gymnum = 0; 121 let gymnum = 0;
...@@ -120,30 +124,28 @@ router.get('/gym', function (req, res) { ...@@ -120,30 +124,28 @@ router.get('/gym', function (req, res) {
120 request({ 124 request({
121 url: url + qs, 125 url: url + qs,
122 method: 'GET' 126 method: 'GET'
123 - }, function (err, response, body) { 127 + }, function(err, response, body) {
124 var gym_result = JSON.parse(body); 128 var gym_result = JSON.parse(body);
125 if (gym_result.PhysicaFitnessTrainingPlace[0].head[1].RESULT.CODE == 'INFO-000') { 129 if (gym_result.PhysicaFitnessTrainingPlace[0].head[1].RESULT.CODE == 'INFO-000') {
126 130
127 gymnum = gym_result.PhysicaFitnessTrainingPlace[0].head[0].list_total_count; 131 gymnum = gym_result.PhysicaFitnessTrainingPlace[0].head[0].list_total_count;
128 console.log(gymnum + "개의 체육관이 존재합니다."); 132 console.log(gymnum + "개의 체육관이 존재합니다.");
129 - res.send(String(gymnum)+"개의 체육관이 존재합니다."); 133 + res.send(String(gymnum) + "개의 체육관이 존재합니다.");
130 - } 134 + } else {
131 - else {
132 135
133 console.log("주변에 체육관이 없습니다."); 136 console.log("주변에 체육관이 없습니다.");
134 res.send("주변에 체육관이 없습니다."); 137 res.send("주변에 체육관이 없습니다.");
135 } 138 }
136 - } 139 + })
137 - )
138 }); 140 });
139 -router.get('/transport', function (req, res) { 141 +router.get('/transport', function(req, res) {
140 res.send(BusCnt); 142 res.send(BusCnt);
141 }); 143 });
142 -router.get('/safe', function (req, res) { 144 +router.get('/safe', function(req, res) {
143 res.send('This is safe'); 145 res.send('This is safe');
144 }); 146 });
145 147
146 -router.get('/culture', function (req, res) { 148 +router.get('/culture', function(req, res) {
147 res.send('This is culture'); 149 res.send('This is culture');
148 }); 150 });
149 151
......
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>🥘 맛집 현황 </h1>
11 + <%for (var i =0; i <store_names.length; i++){%>
12 + <li>
13 + <%=store_names[i].RESTRT_NM%>
14 + </li>
15 +
16 + <%}%>
17 + <h3>총 맛집 개수 :
18 + <%=store_names.length%>
19 + </h3>
20 + <h1>🍔 패스트푸드점 현황 </h1>
21 +
22 +</body>
23 +
24 +</html>
...\ No newline at end of file ...\ No newline at end of file