Toggle navigation
Toggle navigation
This project
Loading...
Sign in
zuzitsu
/
UR_Village
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Suyeon Jung
2020-12-07 06:31:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3229080430cde4ea0163000ccc485f62124bd616
32290804
1 parent
ae36b95e
Complete gym category
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
14 deletions
routes/category.js
views/gym_result.ejs
routes/category.js
View file @
3229080
...
...
@@ -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
)
{
...
...
views/gym_result.ejs
0 → 100644
View file @
3229080
<!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
Please
register
or
login
to post a comment