서연진

Add ejs

......@@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"dotenv": "^10.0.0",
"ejs": "^3.1.6",
"express": "^4.17.1",
"mysql": "^2.18.1",
"path": "^0.12.7",
......
......@@ -5,9 +5,10 @@ const HTTPS = require("https");
const mysql = require('mysql');
var address;
var json_data = [];
const app = express();
const domain = "2020105635.oss2021.tk";
const domain = "2020105619.oss2021.tk";
const sslport = 8080;
const dotenv = require('dotenv').config(); //dotenv를 사용하기 위해서 dotenv 라이브러리를 불러온 뒤, config() 메소드를 호출
......@@ -21,19 +22,31 @@ mysqlConObj.open(db); //db 연결
db.query('SELECT * FROM csvdata.csvdata', function (error, results, fields) {
if (error) {
throw(error);
throw (error);
}
console.log(results.length);
});
app.get("/", function (req, res) {
res.sendFile(path.join(__dirname + "/main.html"));
});
app.set("views", __dirname + "/views");
app.set("view engine", "ejs");
app.get("/geolocation", function (req, res) {
address = req.query.address;
console.log(address);
res.sendFile(path.join(__dirname + "/kakao/kakaomap.html"));
db.query('SELECT * FROM csvdata.csvdata', function (error, results, fields) {
if (error) {
throw (error);
}
for (var i = 0; i < results.length; i++) {
if (results[i].city_country == address) {
json_data.push(results[i]);
}
}
});
res.render('kakaomap', { 'data': json_data })
// res.sendFile(path.join(__dirname + "/kakao/kakaomap.html"), { json_data: json_data });
});
try {
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTR-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HomePurchaseAgePrediction</title>
<link rel="stylesheet" href="css/style2.css" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;500;700;900&display=swap"
rel="stylesheet" />
</head>
<body>
<nav>
<p>js data : <%=data[0].add_adress%>
</p>
<h1 onClick="location.href='/'">Home Purchase Age Prediction</h1>
</nav>
<main>
<div id="info"></div>
<div id="home_info">
<div id="map"></div>
<ul id="house_list">
<div>LIST</div>
</ul>
</div>
</main>
<script type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=17cbb7795b615d8f1f0595f972e26c0f&libraries=services,clusterer,drawing"></script>
<script type="text/javascript" src="../js/next_page.js"></script>
<% if(data){ %>
<% for(let i=0;i < data.length;i++) { %>
NAME : <%= data[i].add_adress %>, AGE : <%= data[i].amount %><br>
<% } %>
<% } %>
</body>
</html>
\ No newline at end of file