Suyeon Jung

Complete gym category

......@@ -326,26 +326,34 @@ router.get('/shop', function(req, res) {
});
router.get('/gym', function(req, res) {
let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
let sigun_cd = SIGUN_CODE;
let gymnum = 0;
let url = 'https://openapi.gg.go.kr/PhysicaFitnessTrainingPlace';
let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`;
let gym_url = 'https://openapi.gg.go.kr/PhysicaFitnessTrainingPlace';
let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}`;
request({
url: url + qs,
url: gym_url + qs,
method: 'GET'
}, function(err, response, body) {
var gym_result = JSON.parse(body);
if (gym_result.PhysicaFitnessTrainingPlace[0].head[1].RESULT.CODE == 'INFO-000') {
if (!err && res.statusCode == 200) {
let gym_result = JSON.parse(body);
let gyms = [];
console.log(gym_result.PhysicaFitnessTrainingPlace[1]);
for (let i = 0; i < gym_result.PhysicaFitnessTrainingPlace[1].row.length; i++) {
gym = gym_result.PhysicaFitnessTrainingPlace[1].row[i];
console.log('gym', gym);
gyms.push(gym);
}
res.render('gym_result', { gyms: gyms });
}
// if (gym_result.PhysicaFitnessTrainingPlace[0].head[1].RESULT.CODE == 'INFO-000') {
gymnum = gym_result.PhysicaFitnessTrainingPlace[0].head[0].list_total_count;
console.log(gymnum + "개의 체육관이 존재합니다.");
res.send(String(gymnum) + "개의 체육관이 존재합니다.");
} else {
// gymnum = gym_result.PhysicaFitnessTrainingPlace[0].head[0].list_total_count;
// console.log(gymnum + "개의 체육관이 존재합니다.");
// res.send(String(gymnum) + "개의 체육관이 존재합니다.");
// } else {
console.log("주변에 체육관이 없습니다.");
res.send("주변에 체육관이 없습니다.");
}
// console.log("주변에 체육관이 없습니다.");
// res.send("주변에 체육관이 없습니다.");
// }
})
});
router.get('/transport', function(req, res) {
......
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>✍️ 결과 페이지</title>
</head>
<body>
<h1>🏋️‍♂️ 운동시설 현황 </h1>
<%for (var i =0; i <gyms.length; i++){%>
<li>
<%=gyms[i].BIZPLC_NM%>
</li>
<%}%>
<h3>총 운동시설 개수 :
<%=gyms.length%>
</h3>
</body>
</html>
\ No newline at end of file