Toggle navigation
Toggle navigation
This project
Loading...
Sign in
kkl
/
Probability Death
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
곽태식
2019-05-31 16:44:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
baaf0e3e9ed1f09741c4bb6d377ec2dd95551cea
baaf0e3e
1 parent
a08a4c56
error
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
24 deletions
lib/socketio.js
lib/socketio.js
View file @
baaf0e3
const
db
=
require
(
'./db.js'
);
const
secret_key
=
require
(
'../keys/api_option'
).
key
;
const
secret_D_key
=
require
(
'../keys/api_option'
).
D_key
;
//사망교통사고 키
//
const secret_D_key = require('../keys/api_option').D_key;//사망교통사고 키
const
requesting
=
require
(
'request'
);
const
lat
=
"37.239795"
;
const
lon
=
"127.083240"
;
...
...
@@ -49,27 +49,7 @@ module.exports = (server, app) => {
})
}
const
req_D_API
=
()
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
requesting
.
get
({
// api를 요청할 주소 -- 시크릿키 입력, 경기도 수원시 설정
url
:
`http://taas.koroad.or.kr/data/rest/accident/death?authKey=
${
secret_D_key
}
searchYear=2018&sido=1300&guGun=1302&type=json`
,
json
:
true
},
//api에게 응답 받았을때 실행되는 callback function
function
(
err
,
api_res
,
api_body
)
{
//err 존재시 promise reject 호출
if
(
err
)
reject
(
err
);
// api의 response이 있을경우 promise resolve 호출
if
(
api_res
)
{
console
.
log
(
"calling api"
);
resolve
(
api_body
);
}
});
})
}
const
API_bundle
=
async
()
=>
{
...
...
@@ -80,7 +60,7 @@ module.exports = (server, app) => {
Heat_index
=
await
req_API
(
"index"
,
"heat"
);
//열지수
Discomport_index
=
await
req_API
(
"index"
,
"th"
);
//불쾌지수
Ultra_Violet_index
=
await
req_API
(
"index"
,
"uv"
);
//자외선지수
let
kts
=
await
req_D_API
();
//
let kts = await req_D_API();
info
=
{
heat
:
Heat_index
.
weather
.
wIndex
.
heatIndex
[
0
].
current
.
index
,
//열지수
...
...
@@ -95,7 +75,7 @@ module.exports = (server, app) => {
warning
:
Current_Weather
.
common
.
alertYn
,
//현재 특보 유무
typhoon
:
Current_Weather
.
common
.
stormYn
,
//현재 태풍
time
:
Current_Weather
.
weather
.
minutely
[
0
].
timeObservation
,
// 불러온 시각
death_prob
:
0
,
//확률
death_prob
:
0
//확률
}
console
.
log
(
"API INFO \n"
,
info
);
...
...
Please
register
or
login
to post a comment