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
안지영
2020-12-02 20:39:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
64c937bfe16c84ce4d0443e3d7f2663a35dda579
64c937bf
1 parent
bd347fa6
Add some functions to category.js
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
12 deletions
routes/category.js
views/category.ejs
routes/category.js
View file @
64c937b
...
...
@@ -8,7 +8,7 @@ let SIGUN_CODE;
let
SIGUNDONG_CODE
;
// 사용자가 index 페이지에서 주소를 입력하고 넘어오면
router
.
post
(
'/'
,
function
(
req
,
res
)
{
router
.
post
(
'/'
,
function
(
req
,
res
)
{
console
.
log
(
req
.
body
);
let
userLocation
=
req
.
body
.
userLocation
;
// let userSi = req.body.si
...
...
@@ -28,7 +28,7 @@ router.post('/', function(req, res) {
},
encoding
:
'UTF-8'
,
}
request
(
kakaoOptions
,
function
(
err
,
res
,
body
)
{
request
(
kakaoOptions
,
function
(
err
,
res
,
body
)
{
if
(
!
err
&&
res
.
statusCode
==
200
)
{
var
result
=
JSON
.
parse
(
body
);
console
.
log
(
'result'
,
result
);
...
...
@@ -42,7 +42,7 @@ router.post('/', function(req, res) {
});
router
.
get
(
'/food'
,
function
(
req
,
res
)
{
router
.
get
(
'/food'
,
function
(
req
,
res
)
{
// 맛집 리스트 조회
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
...
...
@@ -53,7 +53,7 @@ router.get('/food', function(req, res) {
request
({
url
:
url
+
qs
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
},
function
(
err
,
response
,
body
)
{
if
(
!
err
&&
res
.
statusCode
==
200
)
{
let
re
=
body
;
console
.
log
(
body
);
...
...
@@ -61,20 +61,89 @@ router.get('/food', function(req, res) {
}
});
});
router
.
get
(
'/school'
,
function
(
req
,
res
)
{
router
.
get
(
'/school'
,
function
(
req
,
res
)
{
res
.
send
(
'This is school'
);
});
router
.
get
(
'/park'
,
function
(
req
,
res
)
{
res
.
send
(
'This is park'
);
router
.
get
(
'/park'
,
function
(
req
,
res
)
{
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
let
sigun_cd
=
41110
;
let
cityparknum
=
0
;
let
url
=
'https://openapi.gg.go.kr/CityPark'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
sigun_cd
}
`
;
request
({
url
:
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
(
"도시공원이 없습니다."
);
}
}
)
//res.send('This is park');
});
router
.
get
(
'/shop'
,
function
(
req
,
res
)
{
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
let
sigun_cd
=
41110
;
let
mallnum
=
0
;
let
url
=
'https://openapi.gg.go.kr/MrktStoreM'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
sigun_cd
}
`
;
request
({
url
:
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
(
"쇼핑몰이 없습니다."
);
}
}
)
});
router
.
get
(
'/gym'
,
function
(
req
,
res
)
{
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
let
sigun_cd
=
41110
;
let
gymnum
=
0
;
let
url
=
'https://openapi.gg.go.kr/PhysicaFitnessTrainingPlace'
;
let
qs
=
`?Type=json&KEY=
${
GYEONGI_API_KEY
}
&SIGUN_CD=
${
sigun_cd
}
`
;
request
({
url
:
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'
)
{
gymnum
=
gym_result
.
PhysicaFitnessTrainingPlace
[
0
].
head
[
0
].
list_total_count
;
console
.
log
(
gymnum
+
"개의 체육관이 존재합니다."
);
res
.
send
(
String
(
gymnum
)
+
"개의 체육관이 존재합니다."
);
}
else
{
console
.
log
(
"주변에 체육관이 없습니다."
);
res
.
send
(
"주변에 체육관이 없습니다."
);
}
}
)
});
router
.
get
(
'/transport'
,
function
(
req
,
res
)
{
router
.
get
(
'/transport'
,
function
(
req
,
res
)
{
res
.
send
(
BusCnt
);
});
router
.
get
(
'/safe'
,
function
(
req
,
res
)
{
router
.
get
(
'/safe'
,
function
(
req
,
res
)
{
res
.
send
(
'This is safe'
);
});
router
.
get
(
'/culture'
,
function
(
req
,
res
)
{
router
.
get
(
'/culture'
,
function
(
req
,
res
)
{
res
.
send
(
'This is culture'
);
});
...
...
views/category.ejs
View file @
64c937b
...
...
@@ -77,7 +77,7 @@
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
쇼핑
</h5>
<p
class=
"card-text"
>
주변 백화점, 마트, 재래시장
</p>
<a
href=
"/category/
culture
"
class=
"btn btn-primary"
>
검사!
</a>
<a
href=
"/category/
shop
"
class=
"btn btn-primary"
>
검사!
</a>
</div>
</div>
<div
class=
"card"
style=
"width: 18rem;"
>
...
...
@@ -85,7 +85,7 @@
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
운동
</h5>
<p
class=
"card-text"
>
주변 운동시설
</p>
<a
href=
"/category/
culture
"
class=
"btn btn-primary"
>
검사!
</a>
<a
href=
"/category/
gym
"
class=
"btn btn-primary"
>
검사!
</a>
</div>
</div>
</div>
...
...
Please
register
or
login
to post a comment