Suyeon Jung

Complete culture category

...@@ -336,7 +336,28 @@ router.get('/safe', function(req, res) { ...@@ -336,7 +336,28 @@ router.get('/safe', function(req, res) {
336 }); 336 });
337 337
338 router.get('/culture', function(req, res) { 338 router.get('/culture', function(req, res) {
339 - res.send('This is culture'); 339 + // 노래방
340 + let sing_url = 'https://openapi.gg.go.kr/Songclub';
341 + let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}`;
342 + request({
343 + url: sing_url + qs,
344 + method: 'GET'
345 + }, function(err, response, body) {
346 + if (!err && res.statusCode == 200) {
347 + let sing_result = JSON.parse(body);
348 + console.log(sing_result);
349 + let sings = [];
350 + for (let i = 0; i < sing_result.Songclub[1].row.length; i++) {
351 + sing = sing_result.Songclub[1].row[i];
352 + // 폐업인 지점 제외
353 + if (!sing['BSN_STATE_NM'].includes('폐업')) {
354 + console.log('sing', sing);
355 + sings.push(sing);
356 + }
357 + }
358 + res.render('culture_result', { sings: sings });
359 + }
360 + });
340 }); 361 });
341 362
342 router.get('/shop', function(req, res) { 363 router.get('/shop', function(req, res) {
......
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 <sings.length; i++){%>
12 + <li>
13 + <%=sings[i].BIZPLC_NM%>
14 + </li>
15 +
16 + <%}%>
17 + <h3>총 노래방 개수 :
18 + <%=sings.length%>
19 + </h3>
20 +
21 +</body>
22 +
23 +</html>
...\ No newline at end of file ...\ No newline at end of file