Toggle navigation
Toggle navigation
This project
Loading...
Sign in
유승근
/
Computer-part-Recommand
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
1
Network
Create a new issue
Commits
Issue Boards
Authored by
Yuseunggeun
2020-06-25 05:58:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e27406cf4d274868de80b1b220473f7c1656d33b
e27406cf
1 parent
33666373
추천 페이지
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
4 deletions
routes/index.js
views/result.ejs
routes/index.js
View file @
e27406c
...
...
@@ -100,6 +100,7 @@ router.get('/rank',function(req,res){
});
});
/*
router.post('/search',function(req,res,next){
console.log('Money : ' + req.body.money);
console.log(req.body);
...
...
@@ -124,8 +125,68 @@ router.post('/search',function(req,res,next){
searchlist : Searchlist,
count : Searchcount
});
});*/
router
.
post
(
'/search'
,
function
(
req
,
res
,
next
){
var
fdata
=
fs
.
readFileSync
(
'GraphicCard-Price.json'
);
//파일읽어오기
var
datastr
=
fdata
.
toString
();
var
pricejson
=
JSON
.
parse
(
datastr
);
var
fdata2
=
fs
.
readFileSync
(
'GraphicCard-Benchmark.json'
);
//파일읽어오기
var
datastr2
=
fdata2
.
toString
();
var
benchmarkjson
=
JSON
.
parse
(
datastr2
);
console
.
log
(
'Money : '
+
req
.
body
.
money
);
console
.
log
(
req
.
body
);
var
Money
=
req
.
body
.
money
;
//입력한 예산
var
pricelist
=
new
Object
();
var
benchmarklist
=
new
Object
();
var
itemlist
=
new
Array
();
var
Searchcount
=
0
;
//console.log(pricejson);
for
(
var
key
in
pricejson
){
var
price
=
Number
(
pricejson
[
key
][
'lprice'
]);
if
(
price
<=
Money
){
//console.log(price);
var
tempitem
=
new
Object
();
tempitem
=
pricejson
[
key
];
tempitem
[
"benchmark"
]
=
benchmarkjson
[
key
][
"benchmark"
];
tempitem
[
'name'
]
=
benchmarkjson
[
key
][
'name'
];
//console.log(tempitem);
itemlist
.
push
(
tempitem
);
//pricelist[key] = pricejson[key];
Searchcount
++
;
}
}
setTimeout
(
function
(){
console
.
log
(
itemlist
);
res
.
render
(
'result'
,{
money
:
Money
,
itemlist
:
itemlist
,
itemcount
:
Searchcount
});
},
1000
);
});
/*
function searching(name){
var api_url = 'https://openapi.naver.com/v1/search/shop?query=' + encodeURI(name); // json 결과
...
...
@@ -173,11 +234,8 @@ async function createDB(){
});
};
createDB();
router.post('/shop', function(req, res) {
var keyword = req.body.word;
req.query.query = keyword;
...
...
@@ -201,5 +259,5 @@ router.post('/shop', function(req, res) {
}
});
});
*/
module
.
exports
=
router
;
\ No newline at end of file
...
...
views/result.ejs
0 → 100644
View file @
e27406c
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<link
rel=
"stylesheet"
href=
"style.css"
>
<link
href=
"https://fonts.googleapis.com/css?family=Cute+Font&display=swap"
rel=
"stylesheet"
>
<style>
body
{
background-color
:
rgb
(
192
,
233
,
192
);
color
:
black
;
margin
:
0
;
padding
:
0
;
}
h1
{
text-align
:
center
;
color
:
red
;
}
img
{
height
:
200px
;
}
#item1
{
color
:
white
;
}
#item2
{
}
#item3
{
}
</style>
</head>
<body>
<h1>
추천 결과
</h1>
<script>
</script>
<h2>
<div
id =
"item1"
>
<
%= itemlist[0]['name'] %>
<br>
<img
src =
<%=
itemlist
[
0
]['
image
']
%
>
>
<br>
성능 :
<
%= itemlist[0]['benchmark'] %>
<br>
가격 :
<
%= itemlist[0]['lprice'] %>원
<br>
<a
href =
<%=itemlist[0]['link']%
>
target=_blank>구매링크
</a>
</div>
</h2>
</body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment