Showing
1 changed file
with
17 additions
and
5 deletions
| ... | @@ -7,7 +7,7 @@ const app = express(); | ... | @@ -7,7 +7,7 @@ const app = express(); |
| 7 | const data = fs.readFileSync('./database.json'); | 7 | const data = fs.readFileSync('./database.json'); |
| 8 | const conf = JSON.parse(data); | 8 | const conf = JSON.parse(data); |
| 9 | const mysql = require('mysql'); | 9 | const mysql = require('mysql'); |
| 10 | -const sslport = 443; | 10 | +const sslport = 23023; |
| 11 | var cookieSession = require('cookie-session') | 11 | var cookieSession = require('cookie-session') |
| 12 | 12 | ||
| 13 | app.use(bodyParser.json()); | 13 | app.use(bodyParser.json()); |
| ... | @@ -43,7 +43,8 @@ const connection = mysql.createConnection({ | ... | @@ -43,7 +43,8 @@ const connection = mysql.createConnection({ |
| 43 | 43 | ||
| 44 | connection.connect(); | 44 | connection.connect(); |
| 45 | 45 | ||
| 46 | -async function DBUpdate() { | 46 | +async function DBUpdate(year, month, day) { |
| 47 | + await console.log(yaer + " " + month + " " + day); | ||
| 47 | await connection.query( | 48 | await connection.query( |
| 48 | `INSERT INTO visiter VALUES (${date.getFullYear()}, ${date.getMonth()},${date.getDate()}, ${count});` | 49 | `INSERT INTO visiter VALUES (${date.getFullYear()}, ${date.getMonth()},${date.getDate()}, ${count});` |
| 49 | ); | 50 | ); |
| ... | @@ -53,15 +54,19 @@ async function DBUpdate() { | ... | @@ -53,15 +54,19 @@ async function DBUpdate() { |
| 53 | var date = new Date(); | 54 | var date = new Date(); |
| 54 | 55 | ||
| 55 | app.get('/', (req, res) => { | 56 | app.get('/', (req, res) => { |
| 56 | - var today = date.getYear() + " " + date.getMonth() + " " + date.getDate(); | 57 | + let year = date.getFullYear(); |
| 58 | + let month = date.getMonth(); | ||
| 59 | + let day = date.getDate(); | ||
| 60 | + var today = year + " " + month + " " + day; | ||
| 57 | 61 | ||
| 58 | setInterval(() => { | 62 | setInterval(() => { |
| 59 | date.setSeconds(date.getSeconds() + 1); | 63 | date.setSeconds(date.getSeconds() + 1); |
| 60 | var hours = date.getHours(); | 64 | var hours = date.getHours(); |
| 61 | var minutes = date.getMinutes(); | 65 | var minutes = date.getMinutes(); |
| 62 | var seconds = date.getSeconds(); | 66 | var seconds = date.getSeconds(); |
| 67 | + console.log(`${hours}:${minutes}:${seconds}`); | ||
| 63 | if (hours === 23 && minutes === 59 && seconds === 59) { | 68 | if (hours === 23 && minutes === 59 && seconds === 59) { |
| 64 | - DBUpdate(); | 69 | + DBUpdate(year, month, day); |
| 65 | } | 70 | } |
| 66 | }, 1000); | 71 | }, 1000); |
| 67 | console.log(req.session.lastVisit); | 72 | console.log(req.session.lastVisit); |
| ... | @@ -84,7 +89,7 @@ app.get('/detail.html', (req, res) => { | ... | @@ -84,7 +89,7 @@ app.get('/detail.html', (req, res) => { |
| 84 | }); | 89 | }); |
| 85 | }); | 90 | }); |
| 86 | 91 | ||
| 87 | -app.get('/api/visiters', (req,res)=>{ | 92 | +app.get('/api/visiters', (req, res) => { |
| 88 | connection.query( | 93 | connection.query( |
| 89 | 'SELECT * FROM visiter', | 94 | 'SELECT * FROM visiter', |
| 90 | (err, rows, fields) => { | 95 | (err, rows, fields) => { |
| ... | @@ -100,6 +105,12 @@ app.get('/statistics.html', (req, res) => { | ... | @@ -100,6 +105,12 @@ app.get('/statistics.html', (req, res) => { |
| 100 | res.end(data); | 105 | res.end(data); |
| 101 | }) | 106 | }) |
| 102 | }) | 107 | }) |
| 108 | + | ||
| 109 | +app.listen(sslport, () => { | ||
| 110 | + console.log(`https server listening on port ${sslport}`) | ||
| 111 | +}) | ||
| 112 | + | ||
| 113 | +/* | ||
| 103 | try { | 114 | try { |
| 104 | const options = { | 115 | const options = { |
| 105 | key: fs.readFileSync('./keys/private.pem'), | 116 | key: fs.readFileSync('./keys/private.pem'), |
| ... | @@ -114,3 +125,4 @@ try { | ... | @@ -114,3 +125,4 @@ try { |
| 114 | console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | 125 | console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); |
| 115 | console.log(error); | 126 | console.log(error); |
| 116 | } | 127 | } |
| 128 | +*/ | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment