Showing
2 changed files
with
81 additions
and
12 deletions
... | @@ -8,7 +8,7 @@ let SIGUN_CODE; | ... | @@ -8,7 +8,7 @@ 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 |
... | @@ -28,7 +28,7 @@ router.post('/', function(req, res) { | ... | @@ -28,7 +28,7 @@ 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); |
... | @@ -42,7 +42,7 @@ router.post('/', function(req, res) { | ... | @@ -42,7 +42,7 @@ router.post('/', function(req, res) { |
42 | }); | 42 | }); |
43 | 43 | ||
44 | 44 | ||
45 | -router.get('/food', function(req, res) { | 45 | +router.get('/food', function (req, res) { |
46 | 46 | ||
47 | // 맛집 리스트 조회 | 47 | // 맛집 리스트 조회 |
48 | let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; | 48 | let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; |
... | @@ -53,7 +53,7 @@ router.get('/food', function(req, res) { | ... | @@ -53,7 +53,7 @@ router.get('/food', function(req, res) { |
53 | request({ | 53 | request({ |
54 | url: url + qs, | 54 | url: url + qs, |
55 | method: 'GET' | 55 | method: 'GET' |
56 | - }, function(err, response, body) { | 56 | + }, function (err, response, body) { |
57 | if (!err && res.statusCode == 200) { | 57 | if (!err && res.statusCode == 200) { |
58 | let re = body; | 58 | let re = body; |
59 | console.log(body); | 59 | console.log(body); |
... | @@ -61,20 +61,89 @@ router.get('/food', function(req, res) { | ... | @@ -61,20 +61,89 @@ router.get('/food', function(req, res) { |
61 | } | 61 | } |
62 | }); | 62 | }); |
63 | }); | 63 | }); |
64 | -router.get('/school', function(req, res) { | 64 | +router.get('/school', function (req, res) { |
65 | res.send('This is school'); | 65 | res.send('This is school'); |
66 | }); | 66 | }); |
67 | -router.get('/park', function(req, res) { | 67 | +router.get('/park', function (req, res) { |
68 | - res.send('This is park'); | 68 | + let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; |
69 | + let sigun_cd = 41110; | ||
70 | + let cityparknum = 0; | ||
71 | + let url = 'https://openapi.gg.go.kr/CityPark'; | ||
72 | + let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`; | ||
73 | + request({ | ||
74 | + url: url + qs, | ||
75 | + method: 'GET' | ||
76 | + }, function (err, response, body) { | ||
77 | + var park_result = JSON.parse(body); | ||
78 | + if (park_result.CityPark[0].head[1].RESULT.CODE == 'INFO-000') { | ||
79 | + cityparknum = park_result.CityPark[0].head[0].list_total_count; | ||
80 | + console.log(cityparknum + "개의 도시공원이 존재합니다."); | ||
81 | + res.send(String(cityparknum) + "개의 도시공원이 존재합니다."); | ||
82 | + } | ||
83 | + else{ | ||
84 | + res.send("도시공원이 없습니다."); | ||
85 | + } | ||
86 | + } | ||
87 | + ) | ||
88 | + //res.send('This is park'); | ||
89 | +}); | ||
90 | + | ||
91 | +router.get('/shop', function (req, res) { | ||
92 | + let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; | ||
93 | + let sigun_cd = 41110; | ||
94 | + let mallnum = 0; | ||
95 | + let url = 'https://openapi.gg.go.kr/MrktStoreM'; | ||
96 | + let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`; | ||
97 | + request({ | ||
98 | + url: url + qs, | ||
99 | + method: 'GET' | ||
100 | + }, function (err, response, body) { | ||
101 | + var shop_result = JSON.parse(body); | ||
102 | + if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') { | ||
103 | + mallnum = shop_result.MrktStoreM[0].head[0].list_total_count; | ||
104 | + console.log(mallnum + "개의 쇼핑몰이 존재합니다."); | ||
105 | + res.send(String(mallnum) + "개의 쇼핑몰이 존재합니다."); | ||
106 | + } | ||
107 | + else{ | ||
108 | + res.send("쇼핑몰이 없습니다."); | ||
109 | + } | ||
110 | + } | ||
111 | + ) | ||
112 | +}); | ||
113 | + | ||
114 | +router.get('/gym', function (req, res) { | ||
115 | + let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; | ||
116 | + let sigun_cd = 41110; | ||
117 | + let gymnum = 0; | ||
118 | + let url = 'https://openapi.gg.go.kr/PhysicaFitnessTrainingPlace'; | ||
119 | + let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`; | ||
120 | + request({ | ||
121 | + url: url + qs, | ||
122 | + method: 'GET' | ||
123 | + }, function (err, response, body) { | ||
124 | + var gym_result = JSON.parse(body); | ||
125 | + if (gym_result.PhysicaFitnessTrainingPlace[0].head[1].RESULT.CODE == 'INFO-000') { | ||
126 | + | ||
127 | + gymnum = gym_result.PhysicaFitnessTrainingPlace[0].head[0].list_total_count; | ||
128 | + console.log(gymnum + "개의 체육관이 존재합니다."); | ||
129 | + res.send(String(gymnum)+"개의 체육관이 존재합니다."); | ||
130 | + } | ||
131 | + else { | ||
132 | + | ||
133 | + console.log("주변에 체육관이 없습니다."); | ||
134 | + res.send("주변에 체육관이 없습니다."); | ||
135 | + } | ||
136 | + } | ||
137 | + ) | ||
69 | }); | 138 | }); |
70 | -router.get('/transport', function(req, res) { | 139 | +router.get('/transport', function (req, res) { |
71 | res.send(BusCnt); | 140 | res.send(BusCnt); |
72 | }); | 141 | }); |
73 | -router.get('/safe', function(req, res) { | 142 | +router.get('/safe', function (req, res) { |
74 | res.send('This is safe'); | 143 | res.send('This is safe'); |
75 | }); | 144 | }); |
76 | 145 | ||
77 | -router.get('/culture', function(req, res) { | 146 | +router.get('/culture', function (req, res) { |
78 | res.send('This is culture'); | 147 | res.send('This is culture'); |
79 | }); | 148 | }); |
80 | 149 | ... | ... |
... | @@ -77,7 +77,7 @@ | ... | @@ -77,7 +77,7 @@ |
77 | <div class="card-body"> | 77 | <div class="card-body"> |
78 | <h5 class="card-title">쇼핑</h5> | 78 | <h5 class="card-title">쇼핑</h5> |
79 | <p class="card-text">주변 백화점, 마트, 재래시장</p> | 79 | <p class="card-text">주변 백화점, 마트, 재래시장</p> |
80 | - <a href="/category/culture" class="btn btn-primary">검사!</a> | 80 | + <a href="/category/shop" class="btn btn-primary">검사!</a> |
81 | </div> | 81 | </div> |
82 | </div> | 82 | </div> |
83 | <div class="card" style="width: 18rem;"> | 83 | <div class="card" style="width: 18rem;"> |
... | @@ -85,7 +85,7 @@ | ... | @@ -85,7 +85,7 @@ |
85 | <div class="card-body"> | 85 | <div class="card-body"> |
86 | <h5 class="card-title">운동</h5> | 86 | <h5 class="card-title">운동</h5> |
87 | <p class="card-text">주변 운동시설</p> | 87 | <p class="card-text">주변 운동시설</p> |
88 | - <a href="/category/culture" class="btn btn-primary">검사!</a> | 88 | + <a href="/category/gym" class="btn btn-primary">검사!</a> |
89 | </div> | 89 | </div> |
90 | </div> | 90 | </div> |
91 | </div> | 91 | </div> | ... | ... |
-
Please register or login to post a comment