배희수
Committed by unknown

mysql 개발 환경 구축 및 생활 기상 지수/사망확률 변수 정의

This diff is collapsed. Click to expand it.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
16 "http-errors": "~1.6.2", 16 "http-errors": "~1.6.2",
17 "morgan": "~1.9.0", 17 "morgan": "~1.9.0",
18 "request": "^2.88.0", 18 "request": "^2.88.0",
19 + "mysql": "^2.16.0",
19 "socket.io": "^2.1.1" 20 "socket.io": "^2.1.1"
20 } 21 }
21 } 22 }
......
1 var express = require('express'); 1 var express = require('express');
2 var router = express.Router(); 2 var router = express.Router();
3 +var mysql = require('mysql');
4 +
5 +var connection = mysql.createConnection({
6 + host : 'ryulth.com',
7 + user : 'kkonzi',
8 + password : 'kkonzi1234',
9 + database : 'kkonzi_test'
10 +});
3 11
4 /* GET home page. */ 12 /* GET home page. */
5 router.get('/', function(req, res, next) { 13 router.get('/', function(req, res, next) {
6 - res.render('index', { title: 'Express' }); 14 + // mysql 세션 연결
15 + connection.connect();
16 + // connection.query('SELECT * FROM ');
17 +
18 + // 자외선지수, 불쾌지수, 열지수, 체감 온도, 바람속도, 현재기온, 하늘 상태, 강우량, 태풍, 낙뢰
19 + var uvr, discomfort, heat, sensibleTem, windSpeed, presentTem, skyState, rainfall, typhoon, lightning;
20 + // 사망 확률
21 + var deathProb;
22 +
23 + deathProb = uvr + discomfort + heat + sensibleTem + windSpeed + presentTem + skyState + rainfall + typhoon + lightning;
24 + res.render('index', {title: 'Express'});
25 +
26 + connecttion.end();
7 }); 27 });
8 28
9 module.exports = router; 29 module.exports = router;
......