Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건희
/
OSSW_Weather_Briefing
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
Seokjin
2022-05-31 04:29:20 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5132bfdfc918c4dfdf5f53a89bd3b819fb8182e3
5132bfdf
1 parent
719d6d54
[UPDATE]mainpageErrorfix,[ADD]RecommendClothes
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
13 deletions
weather_briefing/server/weather.js
weather_briefing/server/weather.js
View file @
5132bfd
...
...
@@ -92,25 +92,76 @@ app.post('/mainpage',(req,res)=>{
}
let
result
=
[];
i
=
0
;
while
(
i
<
a
.
length
){
let
str
=
CurDay
+
' '
+
add
+
'의 '
+
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
]
+
'시 기온은 '
+
a
[
i
].
fcstValue
+
'이고, 강수확률은 '
+
a
[
i
+
1
].
fcstValue
+
'이다.'
;
result
.
push
(
str
);
i
+=
2
;
}
//정보를 string으로 저장.
// while(i<a.length){
// let
Json={today:CurDay,time:a[i].fcstTime[0]+a[i].fcstTime[1],temperature:a[i].fcstValue,rainPer:a[i+1].baseTime.fcstValue}
;
// result.push(
Json
);
// let
str=CurDay+' '+add+'의 '+a[i].fcstTime[0]+a[i].fcstTime[1]+'시 기온은 '+a[i].fcstValue+'이고, 강수확률은 '+a[i+1].fcstValue+'이다.'
;
// result.push(
str
);
// i+=2;
// }//정보를 Json형식으로 저장.
//}//정보를 string으로 저장.
while
(
i
<
a
.
length
){
let
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
temperature
:
a
[
i
].
fcstValue
,
rainPer
:
a
[
i
+
1
].
fcstValue
};
result
.
push
(
Json
);
i
+=
2
;
}
//정보를 Json형식으로 저장.
//return result를 해주고 싶은데 방법을 잘 모르겠음
res
.
send
(
result
);
});
//pop:강수확률 tmp:한시간 기온
});
//시간대별 괜찮은 옷
app
.
post
(
'/clothes'
,
(
req
,
res
)
=>
{
request
({
url
:
url
+
queryParams
,
method
:
'GET'
},
function
(
error
,
response
,
body
)
{
let
ex
=
JSON
.
parse
(
body
);
let
item
=
ex
.
response
.
body
.
items
.
item
;
// console.log(items);
let
i
=
0
;
let
a
=
[];
while
(
item
[
i
].
fcstDate
==
CurDay
){
if
(
item
[
i
].
category
==
'POP'
||
item
[
i
].
category
==
'TMP'
){
a
.
push
(
item
[
i
]);
}
i
+=
1
;
}
let
result
=
[];
i
=
0
;
let
Json
=
{};
while
(
i
<
a
.
length
){
let
umb
=
0
if
(
Number
(
a
[
i
+
1
].
fcstValue
)
>
0
){
umb
=
1
// 비가올 확률이 있을 시 우산을 챙김
};
if
(
Number
(
a
[
i
].
fcstValue
)
>=
28
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"반팔, 민소매, 원피스"
,
pants
:
"반바지"
,
umbrella
:
umb
};
}
else
if
(
Number
(
a
[
i
].
fcstValue
)
<
28
&&
Number
(
a
[
i
].
fcstValue
)
>=
23
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"반팔, 얇은 셔츠"
,
pants
:
"반바지, 면바지"
,
umbrella
:
umb
};
}
else
if
(
Number
(
a
[
i
].
fcstValue
)
<
23
&&
Number
(
a
[
i
].
fcstValue
)
>=
20
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"얇은 가디건, 긴팔"
,
pants
:
"면바지, 청바지"
,
umbrella
:
umb
};
}
else
if
(
Number
(
a
[
i
].
fcstValue
)
<
20
&&
Number
(
a
[
i
].
fcstValue
)
>=
17
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"얇은 니트, 맨투맨, 가디건"
,
pants
:
"면바지"
,
umbrella
:
umb
};
}
else
if
(
Number
(
a
[
i
].
fcstValue
)
<
17
&&
Number
(
a
[
i
].
fcstValue
)
>=
12
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"자켓, 가디건, 야상"
,
pants
:
"스타킹, 청바지, 면바지"
,
umbrella
:
umb
};
}
else
if
(
Number
(
a
[
i
].
fcstValue
)
<
12
&&
Number
(
a
[
i
].
fcstValue
)
>=
9
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"자켓, 트렌치코트, 야상, 니트"
,
pants
:
"청바지, 스타킹"
,
umbrella
:
umb
};
}
else
if
(
Number
(
a
[
i
].
fcstValue
)
<
9
&&
Number
(
a
[
i
].
fcstValue
)
>=
5
){
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"코트, 가죽자켓, 히트텍, 니트"
,
pants
:
"청바지, 레깅스"
,
umbrella
:
umb
};
}
else
{
Json
=
{
today
:
CurDay
,
time
:
a
[
i
].
fcstTime
[
0
]
+
a
[
i
].
fcstTime
[
1
],
top
:
"패딩, 두꺼운코트, 목도리"
,
pants
:
"기모제품, 내복바지"
,
umbrella
:
umb
};
}
result
.
push
(
Json
);
i
+=
2
;
}
res
.
send
(
result
);
});
});
// app.post('/mainpage', (req, res) => {
// });
app
.
listen
(
4000
,
()
=>
console
.
log
(
'Server On 5000'
));
\ No newline at end of file
app
.
listen
(
4000
,
()
=>
console
.
log
(
'Server On 4000'
));
\ No newline at end of file
...
...
Please
register
or
login
to post a comment