Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이찬
/
opensource_term_project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
이찬
2020-06-21 00:03:24 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b65d922cedfd6f8f698edc0470cc183c2aec258e
b65d922c
1 parent
d277b40c
핫픽스
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
37 deletions
app.js
app.js
View file @
b65d922
...
...
@@ -9,6 +9,8 @@ const conf = JSON.parse(data);
const
mysql
=
require
(
'mysql'
);
const
sslport
=
23023
;
var
cookieSession
=
require
(
'cookie-session'
)
var
schedule
=
require
(
'node-schedule'
);
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
...
...
@@ -18,8 +20,6 @@ app.use('/css', express.static(__dirname + '/css'));
app
.
use
(
'/html'
,
express
.
static
(
__dirname
+
'/html'
));
app
.
use
(
'/img'
,
express
.
static
(
__dirname
+
'/img'
));
var
count
=
0
;
app
.
set
(
'trust proxy'
,
1
);
app
.
use
(
cookieSession
({
...
...
@@ -41,34 +41,25 @@ const connection = mysql.createConnection({
});
var
date
=
new
Date
();
let
year
=
date
.
getFullYear
();
let
month
=
date
.
getMonth
();
let
day
=
date
.
getDate
();
var
count
=
0
;
connection
.
connect
();
async
function
DBUpdate
(
year
,
month
,
day
)
{
await
console
.
log
(
yae
r
+
" "
+
month
+
" "
+
day
);
await
connection
.
query
(
`INSERT INTO visiter VALUES (
${
date
.
getFullYear
()}
,
${
date
.
getMonth
()}
,
${
date
.
getDate
()
}
,
${
count
}
);`
schedule
.
scheduleJob
({
hour
:
23
,
minute
:
59
,
second
:
1
},
function
(
)
{
console
.
log
(
yea
r
+
" "
+
month
+
" "
+
day
);
connection
.
query
(
`INSERT INTO visiter VALUES (
${
year
}
,
${
month
+
1
}
,
${
day
}
,
${
count
}
);`
);
count
=
await
0
;
}
var
date
=
new
Date
();
count
=
0
;
});
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
let
year
=
date
.
getFullYear
();
let
month
=
date
.
getMonth
();
let
day
=
date
.
getDate
();
var
today
=
year
+
" "
+
month
+
" "
+
day
;
setInterval
(()
=>
{
date
.
setSeconds
(
date
.
getSeconds
()
+
1
);
var
hours
=
date
.
getHours
();
var
minutes
=
date
.
getMinutes
();
var
seconds
=
date
.
getSeconds
();
console
.
log
(
`
${
hours
}
:
${
minutes
}
:
${
seconds
}
`
);
if
(
hours
===
23
&&
minutes
===
59
&&
seconds
===
59
)
{
DBUpdate
(
year
,
month
,
day
);
}
},
1000
);
console
.
log
(
req
.
session
.
lastVisit
);
if
(
req
.
session
.
lastVisit
!=
today
)
{
req
.
session
.
lastVisit
=
today
;
...
...
@@ -76,16 +67,28 @@ app.get('/', (req, res) => {
}
fs
.
readFile
(
path
.
join
(
__dirname
,
'html'
,
'index.html'
),
(
err
,
data
)
=>
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html'
});
console
.
log
(
count
);
res
.
end
(
data
);
try
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html'
});
console
.
log
(
count
);
res
.
end
(
data
);
}
catch
(
err
)
{
res
.
writeHead
(
404
,
()
=>
{
console
.
log
(
"Page Not Found!"
)
});
}
})
});
app
.
get
(
'/detail.html'
,
(
req
,
res
)
=>
{
fs
.
readFile
(
path
.
join
(
__dirname
,
'html'
,
'detail.html'
),
(
err
,
data
)
=>
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
try
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
}
catch
(
err
)
{
res
.
writeHead
(
404
,
()
=>
{
console
.
log
(
"Page Not Found!"
)
});
};
});
});
...
...
@@ -101,16 +104,18 @@ app.get('/api/visiters', (req, res) => {
app
.
get
(
'/statistics.html'
,
(
req
,
res
)
=>
{
fs
.
readFile
(
path
.
join
(
__dirname
,
'html'
,
'statistics.html'
),
(
err
,
data
)
=>
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
})
try
{
res
.
writeHead
(
200
,
{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
}
catch
(
err
)
{
res
.
writeHead
(
404
,
()
=>
{
console
.
log
(
"Page Not Found!"
)
});
};
});
})
app
.
listen
(
sslport
,
()
=>
{
console
.
log
(
`https server listening on port
${
sslport
}
`
)
})
/*
try
{
const
options
=
{
key
:
fs
.
readFileSync
(
'./keys/private.pem'
),
...
...
@@ -124,5 +129,4 @@ try {
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
*/
\ No newline at end of file
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment