Showing
1 changed file
with
13 additions
and
8 deletions
... | @@ -5,6 +5,7 @@ const HTTPS = require("https"); | ... | @@ -5,6 +5,7 @@ const HTTPS = require("https"); |
5 | const mysql = require('mysql'); | 5 | const mysql = require('mysql'); |
6 | 6 | ||
7 | var address; | 7 | var address; |
8 | +var json_data=[]; | ||
8 | 9 | ||
9 | const app = express(); | 10 | const app = express(); |
10 | const domain = "2020105635.oss2021.tk"; | 11 | const domain = "2020105635.oss2021.tk"; |
... | @@ -19,23 +20,27 @@ app.use(express.static(path.join(__dirname, "public"))); | ... | @@ -19,23 +20,27 @@ app.use(express.static(path.join(__dirname, "public"))); |
19 | 20 | ||
20 | mysqlConObj.open(db); //db 연결 | 21 | mysqlConObj.open(db); //db 연결 |
21 | 22 | ||
22 | -db.query('SELECT * FROM csvdata.csvdata', function (error, results, fields) { | ||
23 | - if (error) { | ||
24 | - throw(error); | ||
25 | - } | ||
26 | - console.log(results.length); | ||
27 | -}); | ||
28 | - | ||
29 | app.get("/", function (req, res) { | 23 | app.get("/", function (req, res) { |
30 | res.sendFile(path.join(__dirname + "/main.html")); | 24 | res.sendFile(path.join(__dirname + "/main.html")); |
31 | }); | 25 | }); |
32 | 26 | ||
33 | app.get("/geolocation", function (req, res) { | 27 | app.get("/geolocation", function (req, res) { |
34 | address = req.query.address; | 28 | address = req.query.address; |
35 | - console.log(address); | 29 | + db.query('SELECT * FROM csvdata.csvdata', function (error, results, fields) { |
30 | + if (error) { | ||
31 | + console.log("ERROR!!"); | ||
32 | + } | ||
33 | + for (var i=0; i<results.length; i++){ | ||
34 | + if(results[i].city_country == address){ | ||
35 | + json_data.push(results[i]); | ||
36 | + } | ||
37 | + } | ||
38 | + res.send(json_data); | ||
39 | + }); | ||
36 | res.sendFile(path.join(__dirname + "/kakao/kakaomap.html")); | 40 | res.sendFile(path.join(__dirname + "/kakao/kakaomap.html")); |
37 | }); | 41 | }); |
38 | 42 | ||
43 | + | ||
39 | try { | 44 | try { |
40 | const option = { | 45 | const option = { |
41 | ca: fs.readFileSync("/etc/letsencrypt/live/" + domain + "/fullchain.pem"), | 46 | ca: fs.readFileSync("/etc/letsencrypt/live/" + domain + "/fullchain.pem"), | ... | ... |
-
Please register or login to post a comment