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:20:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ae36b95ed84ccf44ad9bc6732904223d8988c4f7
ae36b95e
1 parent
83946f41
Complete shop category
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
14 deletions
routes/category.js
views/shop_result.ejs
routes/category.js
View file @
ae36b95
...
...
@@ -181,10 +181,9 @@ router.post('/', function(req, res) {
router
.
get
(
'/food'
,
function
(
req
,
res
)
{
// 맛집 리스트 조회
let
sigun_cd
=
SIGUN_CODE
;
let
url
=
'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt'
;
let
fastfood_url
=
'https://openapi.gg.go.kr/Genrestrtfastfood'
let
qs
=
`?KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
sigun_cd
}
&Type=json`
;
let
qs
=
`?KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
SIGUN_CODE
}
&Type=json`
;
request
({
url
:
url
+
qs
,
...
...
@@ -295,23 +294,34 @@ router.get('/park', function(req, res) {
});
router
.
get
(
'/shop'
,
function
(
req
,
res
)
{
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
let
sigun_cd
=
SIGUN_CODE
;
let
mallnum
=
0
;
let
url
=
'https://openapi.gg.go.kr/MrktStoreM'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
sigun_cd
}
`
;
let
shop_
url
=
'https://openapi.gg.go.kr/MrktStoreM'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
SIGUN_CODE
}
`
;
request
({
url
:
url
+
qs
,
url
:
shop_
url
+
qs
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
var
shop_result
=
JSON
.
parse
(
body
);
if
(
shop_result
.
MrktStoreM
[
0
].
head
[
1
].
RESULT
.
CODE
==
'INFO-000'
)
{
mallnum
=
shop_result
.
MrktStoreM
[
0
].
head
[
0
].
list_total_count
;
console
.
log
(
mallnum
+
"개의 쇼핑몰이 존재합니다."
);
res
.
send
(
String
(
mallnum
)
+
"개의 쇼핑몰이 존재합니다."
);
}
else
{
res
.
send
(
"쇼핑몰이 없습니다."
);
if
(
!
err
&&
res
.
statusCode
==
200
)
{
let
shop_result
=
JSON
.
parse
(
body
);
let
shops
=
[];
for
(
let
i
=
0
;
i
<
shop_result
.
MrktStoreM
[
1
].
row
.
length
;
i
++
)
{
shop
=
shop_result
.
MrktStoreM
[
1
].
row
[
i
];
// 폐업인 지점 제외
console
.
log
(
'shop'
,
shop
);
shops
.
push
(
shop
);
}
res
.
render
(
'shop_result'
,
{
shops
:
shops
});
}
// var shop_result = JSON.parse(body);
// if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') {
// mallnum = shop_result.MrktStoreM[0].head[0].list_total_count;
// console.log(mallnum + "개의 쇼핑몰이 존재합니다.");
// res.send(String(mallnum) + "개의 쇼핑몰이 존재합니다.");
// } else {
// res.send("쇼핑몰이 없습니다.");
// }
})
});
...
...
views/shop_result.ejs
0 → 100644
View file @
ae36b95
<!DOCTYPE html>
<html
lang=
"ko"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
✍️ 결과 페이지
</title>
</head>
<body>
<h1>
🛍 쇼핑몰 현황(시장, 상가, 마트)
</h1>
<
%for (var i =0; i
<shops
.
length
;
i
++){%
>
<li>
<
%=shops[i].MARKET_NM%>
</li>
<
%}%>
<h3>
총 쇼핑몰 개수 :
<
%=shops.length%>
</h3>
</body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment