Ojimin

Remove api.js

...@@ -2,3 +2,5 @@ node_modules/ ...@@ -2,3 +2,5 @@ node_modules/
2 2
3 package-lock.json 3 package-lock.json
4 4
5 +#dotenv environment variables file
6 +.env
...\ No newline at end of file ...\ No newline at end of file
......
1 -const express =require('express');
2 -const mysql = require('mysql');
3 -const app = express();
4 -const dotenv = require('dotenv').config(); //dotenv를 사용하기 위해서 dotenv 라이브러리를 불러온 뒤, config() 메소드를 호출
5 -const mysqlConObj = require('./config/mysql'); //config의 mysql파일을 가져와 mysqlConnection 객체 사용
6 -const db = mysqlConObj.init();
7 -
8 -mysqlConObj.open(db); //db 연결
9 -
10 -
11 -
12 -
...@@ -14,8 +14,6 @@ const mysqlConnection = { ...@@ -14,8 +14,6 @@ const mysqlConnection = {
14 con.connect(err => { 14 con.connect(err => {
15 if(err){ 15 if(err){
16 console.log("MySQL 연결 실패 : ",err); 16 console.log("MySQL 연결 실패 : ",err);
17 - } else{
18 - console.log("MySQL 연결 성공");
19 } 17 }
20 }); 18 });
21 }, 19 },
......
...@@ -2,14 +2,28 @@ const express = require("express"); ...@@ -2,14 +2,28 @@ const express = require("express");
2 const fs = require("fs"); 2 const fs = require("fs");
3 const path = require("path"); 3 const path = require("path");
4 const HTTPS = require("https"); 4 const HTTPS = require("https");
5 +const mysql = require('mysql');
5 6
6 const app = express(); 7 const app = express();
7 const domain = "2020105635.oss2021.tk"; 8 const domain = "2020105635.oss2021.tk";
8 const sslport = 8080; 9 const sslport = 8080;
9 10
11 +const dotenv = require('dotenv').config(); //dotenv를 사용하기 위해서 dotenv 라이브러리를 불러온 뒤, config() 메소드를 호출
12 +const mysqlConObj = require('./config/mysql'); //config의 mysql파일을 가져와 mysqlConnection 객체 사용
13 +const db = mysqlConObj.init();
14 +
10 app.use(express.static(path.join(__dirname, "kakao"))); 15 app.use(express.static(path.join(__dirname, "kakao")));
11 app.use(express.static(path.join(__dirname, "public"))); 16 app.use(express.static(path.join(__dirname, "public")));
12 17
18 +mysqlConObj.open(db); //db 연결
19 +
20 +db.query('SELECT * FROM csvdata.csvdata', function (error, results, fields) {
21 + if (error) {
22 + throw(error);
23 + }
24 + console.log(results[0].amount);
25 +});
26 +
13 app.get("/", function (req, res) { 27 app.get("/", function (req, res) {
14 res.sendFile(path.join(__dirname + "/main.html")); 28 res.sendFile(path.join(__dirname + "/main.html"));
15 }); 29 });
......