Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍예림
/
emergency_room_ChatBot
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
홍예림
2022-11-28 14:46:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f94da2351253f9f3ceb6a1fb6478b07256fd0704
f94da235
1 parent
0c414e65
Directions_15_sample_app1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
Directions_15_sample_app.js
Directions_15_sample_app.js
0 → 100644
View file @
f94da23
const
express
=
require
(
'express'
);
const
app
=
express
();
const
request
=
require
(
'request'
)
const
ID
=
'12rhzhzq7g'
;
const
KEY
=
'FhD45P91TxG2820MadrsiPOUjI6bQMJhddnHZIeI'
;
app
.
post
(
'/direction'
,
function
(
req
,
res
){
let
data_body
=
req
.
body
;
var
num
=
data_body
.
number
;
let
count
=
0
;
while
(
count
<
num
){
const
_url
=
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start='
+
data_body
.
address
.
current_address
.
x
+
','
+
data_body
.
address
.
current_address
.
y
+
'&goal='
+
data_body
.
hospital_data
[
count
].
x
+
','
+
data_body
.
hospital_data
[
count
].
y
+
'&option=trafast'
;
}
request
.
post
(
{
method
:
'GET'
,
url
:
_url
,
headers
:
{
'X-NCP-APIGW-API-KEY-ID'
:
ID
,
'X-NCP-APIGW-API-KEY'
:
KEY
}
},(
error
,
res
,
body
)
=>
{
let
body
=
JSON
.
parse
(
res
.
body
);
var
distance
=
body
.
route
.
trafast
[
0
].
summary
.
distance
/
1000
;
// km 단위
var
duration
=
body
.
route
.
trafast
[
0
].
summary
.
duration
/
1000
/
60
;
// 분 단위dy
data_body
.
hospital_data
[
count
].
distance
=
distance
;
data_body
.
hospital_data
[
count
].
duration
=
duration
;
}
);
count
+=
1
;
res
.
send
(
data_body
)
}
)
Please
register
or
login
to post a comment