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-18 18:39:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f8a9a25e75b222e295cda0f9d89334a8e66fe07a
f8a9a25e
1 parent
21b1d5d0
핫픽스
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
app.js
app.js
View file @
f8a9a25
...
...
@@ -7,7 +7,7 @@ const app = express();
const
data
=
fs
.
readFileSync
(
'./database.json'
);
const
conf
=
JSON
.
parse
(
data
);
const
mysql
=
require
(
'mysql'
);
const
sslport
=
44
3
;
const
sslport
=
2302
3
;
var
cookieSession
=
require
(
'cookie-session'
)
app
.
use
(
bodyParser
.
json
());
...
...
@@ -43,7 +43,8 @@ const connection = mysql.createConnection({
connection
.
connect
();
async
function
DBUpdate
()
{
async
function
DBUpdate
(
year
,
month
,
day
)
{
await
console
.
log
(
yaer
+
" "
+
month
+
" "
+
day
);
await
connection
.
query
(
`INSERT INTO visiter VALUES (
${
date
.
getFullYear
()}
,
${
date
.
getMonth
()}
,
${
date
.
getDate
()}
,
${
count
}
);`
);
...
...
@@ -53,15 +54,19 @@ async function DBUpdate() {
var
date
=
new
Date
();
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
var
today
=
date
.
getYear
()
+
" "
+
date
.
getMonth
()
+
" "
+
date
.
getDate
();
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
();
DBUpdate
(
year
,
month
,
day
);
}
},
1000
);
console
.
log
(
req
.
session
.
lastVisit
);
...
...
@@ -84,7 +89,7 @@ app.get('/detail.html', (req, res) => {
});
});
app
.
get
(
'/api/visiters'
,
(
req
,
res
)
=>
{
app
.
get
(
'/api/visiters'
,
(
req
,
res
)
=>
{
connection
.
query
(
'SELECT * FROM visiter'
,
(
err
,
rows
,
fields
)
=>
{
...
...
@@ -100,6 +105,12 @@ app.get('/statistics.html', (req, res) => {
res
.
end
(
data
);
})
})
app
.
listen
(
sslport
,
()
=>
{
console
.
log
(
`https server listening on port
${
sslport
}
`
)
})
/*
try {
const options = {
key: fs.readFileSync('./keys/private.pem'),
...
...
@@ -114,3 +125,4 @@ try {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
*/
\ No newline at end of file
...
...
Please
register
or
login
to post a comment