Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김태민
/
OpenSource_Project
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
seungmi
2019-12-01 14:03:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b15551abd082e1770bac76b658b0e6b5cfed7967
b15551ab
1 parent
a744d997
post 함수 버그 수정
post함수의 비동기로 인한 write, read 함수 에러 내용수정
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
app.js
프로젝트 계획서.docx
app.js
View file @
b15551a
...
...
@@ -38,8 +38,8 @@ app.get(['/food', '/food/:id'], function(req, res) {
//사용자가 호출한 search page
app
.
post
(
'/food/search'
,
function
(
req
,
res
)
{
var
title
=
req
.
body
.
title
;
res
.
redirect
(
"https://www.google.com/search?q="
+
title
+
"&oq="
+
title
+
"&aqs=chrome..69i57j0l3j69i60j69i61.3149j0j9&sourceid=chrome&ie=UTF-8"
)
var
title
=
req
.
body
.
title
;
res
.
redirect
(
"https://www.google.com/search?q="
+
title
+
"&oq="
+
title
+
"&aqs=chrome..69i57j0l3j69i60j69i61.3149j0j9&sourceid=chrome&ie=UTF-8"
)
})
//사용자가 호출한 recommendation page
...
...
@@ -60,13 +60,14 @@ app.post('/food/recommendation', function(req, res) {
if
((
!
price
||
users
[
foods
][
'price'
]
==
price
)
&&
(
!
shape
||
users
[
foods
][
'shape'
]
==
shape
)
&&
(
!
kinds
||
users
[
foods
][
'kinds'
]
==
kinds
))
{
list
.
food
.
push
(
foods
);
}
// $('<li>').text(foods).appendTo('#users');
}
fs
.
writeFile
(
'data/temp.json'
,
JSON
.
stringify
(
list
),
"utf8"
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
status
(
500
).
send
(
'Internal Server Error'
);
}
});
}
else
{
fs
.
readFile
(
'data/temp.json'
,
'utf8'
,
function
(
err
,
data
)
{
if
(
err
)
{
...
...
@@ -74,25 +75,25 @@ app.post('/food/recommendation', function(req, res) {
res
.
status
(
500
).
send
(
'Internal Server Error'
);
}
else
{
var
food
=
JSON
.
parse
(
data
)[
'food'
];
var
length
=
food
.
length
;
var
length
=
food
.
length
;
var
rand
=
Math
.
floor
(
Math
.
random
()
*
length
);
//(Math.random() * (max - min)) + min
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
if
(
rand
==
i
)
{
var
food_value
=
food
[
i
];
break
;
// $('<li>').text(foods).appendTo('#users');
}
}
var
food_value
=
food
[
rand
];
console
.
log
(
rand
);
res
.
render
(
'print.ejs'
,
{
title
:
'Recommendation'
,
description
:
'We recommend this...'
,
randvalue
:
food_value
});
});
//rander closed
}
});
});
//readFile closed
}
});
})
});
//writeFile closed
}
});
//readFile closed
});
//post closed
app
.
listen
(
3000
,
function
()
{
...
...
프로젝트 계획서.docx
View file @
b15551a
No preview for this file type
Please
register
or
login
to post a comment