Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오지민
/
HomePurchaseAgePrediction
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
서연진
2021-06-09 15:43:13 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
38de1c33d01a7da95f127a56c6636d2705c42ac6
38de1c33
1 parent
62802305
Add ejs
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
5 deletions
package.json
server.js
views/kakaomap.ejs
package.json
View file @
38de1c3
...
...
@@ -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"
,
...
...
server.js
View file @
38de1c3
...
...
@@ -5,9 +5,10 @@ const HTTPS = require("https");
const
mysql
=
require
(
'mysql'
);
var
address
;
var
json_data
=
[];
const
app
=
express
();
const
domain
=
"20201056
35
.oss2021.tk"
;
const
domain
=
"20201056
19
.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
{
...
...
views/kakaomap.ejs
0 → 100644
View file @
38de1c3
<!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
Please
register
or
login
to post a comment