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:10:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
83946f410166e488e0d8319545c770bd9f5a28d9
83946f41
1 parent
5b93f872
Complete park category
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
16 deletions
routes/category.js
views/park_result.ejs
routes/category.js
View file @
83946f4
...
...
@@ -208,7 +208,7 @@ router.get('/food', function(req, res) {
},
function
(
err
,
response
,
body
)
{
if
(
!
err
&&
res
.
statusCode
==
200
)
{
let
fast_food_result
=
JSON
.
parse
(
body
);
let
fast_store_names
=
[]
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
];
// 폐업인 지점 제외
...
...
@@ -240,7 +240,6 @@ router.get('/school', function(req, res) {
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
);
...
...
@@ -254,7 +253,6 @@ router.get('/school', function(req, res) {
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
);
...
...
@@ -266,23 +264,33 @@ router.get('/school', function(req, res) {
})
});
router
.
get
(
'/park'
,
function
(
req
,
res
)
{
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
let
sigun_cd
=
SIGUN_CODE
;
let
cityparknum
=
0
;
let
url
=
'https://openapi.gg.go.kr/CityPark'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
sigun_cd
}
`
;
// let cityparknum = 0;
let
citypark_url
=
'https://openapi.gg.go.kr/CityPark'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
SIGUN_CODE
}
`
;
request
({
url
:
url
+
qs
,
url
:
citypark_
url
+
qs
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
var
park_result
=
JSON
.
parse
(
body
);
if
(
park_result
.
CityPark
[
0
].
head
[
1
].
RESULT
.
CODE
==
'INFO-000'
)
{
cityparknum
=
park_result
.
CityPark
[
0
].
head
[
0
].
list_total_count
;
console
.
log
(
cityparknum
+
"개의 도시공원이 존재합니다."
);
res
.
send
(
String
(
cityparknum
)
+
"개의 도시공원이 존재합니다."
);
}
else
{
res
.
send
(
"도시공원이 없습니다."
);
// console.log('park_result', park_result.CityPark[0].head);
if
(
!
err
&&
res
.
statusCode
==
200
)
{
let
city_park_result
=
JSON
.
parse
(
body
);
console
.
log
(
'park'
,
city_park_result
)
let
city_park_names
=
[];
for
(
let
i
=
0
;
i
<
city_park_result
.
CityPark
[
1
].
row
.
length
;
i
++
)
{
city_park_name
=
city_park_result
.
CityPark
[
1
].
row
[
i
];
city_park_names
.
push
(
city_park_name
);
}
res
.
render
(
'park_result'
,
{
city_park_names
:
city_park_names
});
}
// if (park_result.CityPark[0].head[1].RESULT.CODE == 'INFO-000') {
// cityparknum = park_result.CityPark[0].head[0].list_total_count;
// console.log(cityparknum + "개의 도시공원이 존재합니다.");
// res.send(String(cityparknum) + "개의 도시공원이 존재합니다.");
// } else {
// res.send("도시공원이 없습니다.");
// }
})
});
...
...
views/park_result.ejs
0 → 100644
View file @
83946f4
<!DOCTYPE html>
<html
lang=
"ko"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
✍️ 결과 페이지
</title>
</head>
<body>
<h1>
🌳 도시공원 현황
</h1>
<
%for (var i =0; i
<city
_park_names
.
length
;
i
++){%
>
<li>
<
%=city_park_names[i].PARK_NM%>
</li>
<
%}%>
<h3>
총 도시공원 개수 :
<
%=city_park_names.length%>
</h3>
</body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment