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-06-03 16:28:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ee1eab0c92bdf4c0ce0179cc7ad6bf3201018b06
ee1eab0c
1 parent
9417d49c
예보페이지 추가
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
189 additions
and
9 deletions
app.js
routes/index.js
routes/new_index.js
views/index.ejs
views/main.ejs
views/new_index.ejs
app.js
View file @
ee1eab0
...
...
@@ -6,6 +6,8 @@ var logger = require('morgan');
var
indexRouter
=
require
(
'./routes/index'
);
var
usersRouter
=
require
(
'./routes/users'
);
var
app
=
express
(),
server
=
require
(
'http'
).
createServer
(
app
),
SOCKETIO
=
require
(
'./lib/socketio.js'
);
...
...
@@ -20,12 +22,16 @@ app.use(express.urlencoded({ extended: false }));
app
.
use
(
cookieParser
());
app
.
use
(
'/'
,
express
.
static
(
path
.
join
(
__dirname
,
'public'
)));
app
.
use
(
'/'
,
express
.
static
(
path
.
join
(
__dirname
,
'code'
)));
app
.
use
(
'/name/:name/birth'
,
express
.
static
(
path
.
join
(
__dirname
,
'public'
)));
app
.
use
(
'/name/:name/birth'
,
express
.
static
(
path
.
join
(
__dirname
,
'code'
)));
app
.
use
(
'/Cname/:Cname/Cbirth'
,
express
.
static
(
path
.
join
(
__dirname
,
'public'
)));
app
.
use
(
'/Cname/:Cname/Cbirth'
,
express
.
static
(
path
.
join
(
__dirname
,
'code'
)));
app
.
use
(
'/Fname/:Fname/Fbirth'
,
express
.
static
(
path
.
join
(
__dirname
,
'public'
)));
app
.
use
(
'/Fname/:Fname/Fbirth'
,
express
.
static
(
path
.
join
(
__dirname
,
'code'
)));
app
.
use
(
'/'
,
indexRouter
);
app
.
use
(
'/users'
,
usersRouter
);
// catch 404 and forward to error handler
app
.
use
(
function
(
req
,
res
,
next
)
{
next
(
createError
(
404
));
...
...
routes/index.js
View file @
ee1eab0
...
...
@@ -5,9 +5,73 @@ var db = require('../lib/db');
/* GET home page. */
router
.
post
(
'/starting'
,
(
req
,
res
)
=>
{
res
.
redirect
(
`/
name/
${
req
.
body
.
name
}
/
birth/
${
req
.
body
.
birth
}
`
);
res
.
redirect
(
`/
Cname/
${
req
.
body
.
name
}
/C
birth/
${
req
.
body
.
birth
}
`
);
})
router
.
get
(
'/name/:name/birth/:birth'
,
(
req
,
res
)
=>
{
router
.
post
(
'/forecasting'
,
(
req
,
res
)
=>
{
res
.
redirect
(
`/Fname/
${
req
.
body
.
name
}
/Fbirth/
${
req
.
body
.
birth
}
`
);
})
router
.
get
(
'/Fname/:Fname/Fbirth/:Fbirth'
,(
req
,
res
)
=>
{
// 렌더링 변수
var
time
=
new
Array
();
// 타임스탬프
var
ptArr
=
new
Array
();
// 현재 온도
var
wsArr
=
new
Array
();
// 풍속
var
rainArr
=
new
Array
();
// 강우량
var
probArr
=
new
Array
();
// 사망 확률
var
dataLen
=
0
;
// 데이터 개수
var
empty
=
0
;
// 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var
sql
=
""
;
// 쿼리
var
count
=
0
;
const
name
=
req
.
params
.
name
;
const
birth
=
req
.
params
.
birth
;
// 이전 10분간 데이터 찾기
sql
=
"SELECT * FROM weather_info WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -20 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
if
(
rows
.
length
==
0
)
{
empty
=
1
;
}
else
{
for
(
var
i
=
rows
.
length
-
1
;
i
>=
0
;
i
--
)
{
probArr
.
unshift
(
rows
[
i
].
prob
);
time
.
unshift
(
rows
[
i
].
time
);
ptArr
.
unshift
(
rows
[
i
].
temperature
);
wsArr
.
unshift
(
rows
[
i
].
wind
);
rainArr
.
unshift
(
rows
[
i
].
rain
);
count
=
count
+
1
;
if
(
count
==
10
){
break
;
}
}
}
dataLen
=
probArr
.
length
;
res
.
render
(
'index'
,
{
empty
,
time
,
ptArr
,
wsArr
,
rainArr
,
probArr
,
dataLen
,
name
,
birth
});
}
});
}
)
router
.
get
(
'/Cname/:Cname/Cbirth/:Cbirth'
,
(
req
,
res
)
=>
{
// 렌더링 변수
var
time
=
new
Array
();
// 타임스탬프
...
...
routes/new_index.js
0 → 100644
View file @
ee1eab0
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
var
db
=
require
(
'../lib/db'
);
/* GET home page. */
router
.
post
(
'/forecasting'
,
(
req
,
res
)
=>
{
res
.
redirect
(
`/name/
${
req
.
body
.
name
}
/birth/
${
req
.
body
.
birth
}
`
);
})
router
.
get
(
'/name/:name/birth/:birth'
,
(
req
,
res
)
=>
{
// 렌더링 변수
var
time
=
new
Array
();
// 타임스탬프
var
ptArr
=
new
Array
();
// 현재 온도
var
wsArr
=
new
Array
();
// 풍속
var
rainArr
=
new
Array
();
// 강우량
var
probArr
=
new
Array
();
// 사망 확률
var
dataLen
=
0
;
// 데이터 개수
var
empty
=
0
;
// 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var
sql
=
""
;
// 쿼리
var
count
=
0
;
const
name
=
req
.
params
.
name
;
const
birth
=
req
.
params
.
birth
;
// 이전 10분간 데이터 찾기
sql
=
"SELECT * FROM weather_info WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -20 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
if
(
rows
.
length
==
0
)
{
empty
=
1
;
}
else
{
for
(
var
i
=
rows
.
length
-
1
;
i
>=
0
;
i
--
)
{
probArr
.
unshift
(
rows
[
i
].
prob
);
time
.
unshift
(
rows
[
i
].
time
);
ptArr
.
unshift
(
rows
[
i
].
temperature
);
wsArr
.
unshift
(
rows
[
i
].
wind
);
rainArr
.
unshift
(
rows
[
i
].
rain
);
count
=
count
+
1
;
if
(
count
==
10
){
break
;
}
}
}
dataLen
=
probArr
.
length
;
res
.
render
(
'index'
,
{
empty
,
time
,
ptArr
,
wsArr
,
rainArr
,
probArr
,
dataLen
,
name
,
birth
});
}
});
}
)
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'main'
);
});
module
.
exports
=
router
;
views/index.ejs
View file @
ee1eab0
<!-- <!DOCTYPE html>
<html lang="ko">
<head>
<head>
<!-- font -->
<link
href=
"https://fonts.googleapis.com/css?family=Nanum+Brush+Script&subset=korean"
rel=
"stylesheet"
/>
<link
href=
"https://fonts.googleapis.com/css?family=Yeon+Sung&subset=korean"
rel=
"stylesheet"
/>
...
...
@@ -41,7 +40,7 @@
<img
src=
"images/indexWallpaper.jpg"
alt=
""
style=
"z-index:-1; min-width: 100%; min-height: 100%"
width=
"50%"
height=
"100%"
>
<div
id=
"banner"
>
<div
id=
"banner"
ani_type=
"fade"
>
<div
id=
"container1"
style=
"width:1260px; height: 400px; margin: 0 auto;"
></div>
<div
style=
"width:1275px; margin:0 auto;"
>
...
...
views/main.ejs
View file @
ee1eab0
...
...
@@ -79,7 +79,7 @@
<h1
style=
"font-size:90px;"
>
당신이 지금 죽을 확률은?
</h1>
</div>
<br><br><br>
<div
style=
"width:100%; text-align: center;"
>
<div
style=
"width:100%; text-align: center;"
>
<form
action=
"/starting"
method=
"post"
>
<div
class=
"form-inline"
>
<label>
이름
</label>
...
...
@@ -88,13 +88,20 @@
<label>
생년월일
</label>
<input
type=
"text"
name=
"birth"
class=
"form-control"
placeholder=
"971009"
style=
"width:200px;"
minlength=
"6"
maxlength=
"6"
>
<br><br><br>
<input
type=
"submit"
value=
"운명보기"
class=
"btn btn-default"
style=
"font-family: 'Yeon Sung', cursive; width:100px;font-weight: bold; font-size: 18px; background-color: white;"
>
<input
type=
"submit"
value=
"운명보기"
class=
"btn btn-danger"
style=
"font-family: 'Yeon Sung', cursive; width:100px;font-weight: bold; font-size: 18px; background-color: white;"
>
</div>
</form>
<form
action=
"/forecasting"
method=
"post"
>
<div
class=
"/forecasting"
method=
"post"
>
<input
type=
"submit"
value=
"미래확인"
class=
"btn btn-default"
style=
"..."
>
</div>
</form>
</div>
</div>
<div
id=
"footer"
>
오픈소스SW개발 곽태식 이승규 강병호
</div>
</body>
...
...
views/new_index.ejs
0 → 100644
View file @
ee1eab0
<head>
<link href="https://fonts.googleapis.com/css?family=Nanum+Brush+Script&subset=korean" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Yeon+Sung&subset=korean" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>당신이 지금 죽을 확률은?</title>
<style type="text/css">
html {
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
/* background: linear-gradient( to bottom, #65799B, rgb(38, 14, 41) ); */
/* background-color:#65799B; */
/* background-image: url("2.jpg");
background-repeat: no-repeat;
background-size: cover; */
}
#banner {
position: absolute;
top: 0;
width: 100%;
}
</style>
</head>
\ No newline at end of file
Please
register
or
login
to post a comment