Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Joung Jiwon
/
OSS-TongGilMut
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
SH
2020-12-10 18:40:26 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d4ca5fc9dce879a26d9bee01f4b12f10535f629e
d4ca5fc9
1 parent
e28513ab
ejs page
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
project/server.js
project/views/index.ejs
project/server.js
0 → 100644
View file @
d4ca5fc
const
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
http
=
require
(
'http'
);
const
app
=
express
();
var
bodyParser
=
require
(
"body-parser"
);
let
path
=
require
(
'path'
);
let
server
=
http
.
createServer
(
app
);
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
'views'
,
path
.
join
(
__dirname
,
'views'
));
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
request
.
post
(
"/"
,
function
(
req
,
res
){
//let sxv = req.render(sx)
//let syv = req.render(sy)
//let exv = req.render(ex)
//let eyv = req.render(ey)
});
app
.
get
(
'/'
,
function
(
req
,
response
)
{
let
requestUrl
=
"https://api.odsay.com/v1/api/searchPubTransPath?SX=127.13973017022232&SY=37.47331630562443&EX=127.08011485487083&EY=37.24312944010195&apiKey=D5/cqOgLNnn/iHrOs3rXewYFNPO6KVQvntHKQ/5muGA"
request
.
get
(
requestUrl
,
(
err
,
res
,
body
)
=>
{
if
(
err
)
{
console
.
log
(
`err =>
${
err
}
`
)
}
else
{
if
(
res
.
statusCode
==
200
)
{
var
result
=
body
var
obj
=
JSON
.
parse
(
result
);
//console.log(`body data => ${result}`)
//console.log('ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ')
var
time
=
(
obj
)[
"result"
][
"path"
][
0
].
info
.
totalTime
var
pay
=
(
obj
)[
"result"
][
"path"
][
0
].
info
.
payment
var
distance
=
(
obj
)[
"result"
][
"path"
][
0
].
info
.
totalDistance
response
.
render
(
'index'
,
{
time
:
time
,
pay
:
pay
,
distance
:
distance
});
}
}
})
});
server
.
listen
(
'3000'
,
'localhost'
,
function
()
{
console
.
log
(
'server listen on port:'
+
server
.
address
().
port
);
})
\ No newline at end of file
project/views/index.ejs
0 → 100644
View file @
d4ca5fc
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment