Suyeon Jung

Complete school category

......@@ -5,6 +5,7 @@ require('dotenv').config();
/* GET home page. */
let SIGUN_CODE;
let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
let user_latitude;
let user_logitude;
let sigun = [{
......@@ -180,7 +181,6 @@ router.post('/', function(req, res) {
router.get('/food', function(req, res) {
// 맛집 리스트 조회
let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
let sigun_cd = SIGUN_CODE;
let url = 'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt';
let fastfood_url = 'https://openapi.gg.go.kr/Genrestrtfastfood'
......@@ -193,7 +193,7 @@ router.get('/food', function(req, res) {
if (!err && res.statusCode == 200) {
let food_result = JSON.parse(body);
// console.log('food_result', food_result.PlaceThatDoATasteyFoodSt[1]);
let store_names = []
let store_names = [];
for (let i = 0; i < food_result.PlaceThatDoATasteyFoodSt[1].row.length; i++) {
// 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR)
store_name = food_result.PlaceThatDoATasteyFoodSt[1].row[i];
......@@ -211,12 +211,13 @@ router.get('/food', function(req, res) {
let fast_store_names = []
for (let i = 0; i < fast_food_result.Genrestrtfastfood[1].row.length; i++) {
fast_store_name = fast_food_result.Genrestrtfastfood[1].row[i];
// 폐업인 지점 제외
if (fast_store_name['BSN_STATE_NM'] != '폐업') {
console.log('fast_store_name', fast_store_name);
fast_store_names.push(fast_store_name);
}
}
res.render('result', { store_names: store_names, fast_store_names: fast_store_names });
res.render('food_result', { store_names: store_names, fast_store_names: fast_store_names });
}
})
......@@ -225,7 +226,44 @@ router.get('/food', function(req, res) {
});
});
router.get('/school', function(req, res) {
res.send('This is school');
let library_url = 'https://openapi.gg.go.kr/Tbggibllbrm';
let institute_url = 'https://openapi.gg.go.kr/TninsttInstutM';
let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}&Type=json`;
request({
url: library_url + qs,
method: 'GET'
}, function(err, response, body) {
if (!err && res.statusCode == 200) {
let library_result = JSON.parse(body);
console.log(library_result);
let library_names = [];
for (let i = 0; i < library_result.Tbggibllbrm[1].row.length; i++) {
// 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR)
library_name = library_result.Tbggibllbrm[1].row[i];
console.log('library_name', library_name);
library_names.push(library_name);
}
request({
url: institute_url + qs,
method: 'GET'
}, function(err, response, body) {
if (!err && res.statusCode == 200) {
let institute_result = JSON.parse(body);
console.log(institute_result);
let institute_names = [];
for (let i = 0; i < institute_result.TninsttInstutM[1].row.length; i++) {
// 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR)
institute_name = institute_result.TninsttInstutM[1].row[i];
console.log('institute_name', institute_name);
institute_names.push(institute_name);
}
res.render('school_result', { library_names: library_names, institute_names: institute_names });
}
})
}
})
});
router.get('/park', function(req, res) {
let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
......
......@@ -36,7 +36,7 @@
<img src="/img/school.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">학군</h5>
<p class="card-text">주변 학교, 학원 환경</p>
<p class="card-text">주변 학원 및 도서관 현황</p>
<a href="/category/school" class="btn btn-primary">검사!</a>
</div>
</div>
......
......@@ -24,7 +24,7 @@
</li>
<%}%>
<h3>총 맛집 개수 :
<h3>패스트푸드점 개수 :
<%=fast_store_names.length%>
</h3>
......
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>✍️ 결과 페이지</title>
</head>
<body>
<h1>📚 도서관 현황 </h1>
<%for (var i =0; i <library_names.length; i++){%>
<li>
<%=library_names[i].LIBRRY_NM%>
</li>
<%}%>
<h3>총 도서관 개수 :
<%=library_names.length%>
</h3>
<h1>📒 학원 현황 </h1>
<%for (var i =0; i <institute_names.length; i++){%>
<li>
<%=institute_names[i].FACLT_NM%>
</li>
<%}%>
<h3>학원 및 교습소 개수 :
<%=institute_names.length%>
</h3>
</body>
</html>
\ No newline at end of file