Toggle navigation
Toggle navigation
This project
Loading...
Sign in
khusat
/
khusat-server
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
박기홍
2020-11-13 22:15:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
42f38bf1b1a7988a873dedd43b70895118e535d9
42f38bf1
1 parent
b0d95b6e
mongoose added
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
0 deletions
.gitignore
README.md
package.json
src/index.js
.gitignore
0 → 100644
View file @
42f38bf
node_modules/
yarn.lock
\ No newline at end of file
README.md
View file @
42f38bf
# khusat_server
type yarn
type yarn start or yarn start:dev
...
...
package.json
0 → 100644
View file @
42f38bf
{
"name"
:
"khusat_server"
,
"version"
:
"1.0.0"
,
"main"
:
"index.js"
,
"repository"
:
"https://github.com/KHUSAT/khusat_server.git"
,
"author"
:
"kyhong222 <kyhong222@naver.com>"
,
"license"
:
"MIT"
,
"dependencies"
:
{
"body-parser"
:
"^1.19.0"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.10.14"
,
"nodemon"
:
"^2.0.6"
},
"scripts"
:
{
"start"
:
"NODE_PATH=src node src"
,
"start:dev"
:
"NODE_PATH=src nodemon --watch src/ src/index.js"
}
}
src/index.js
0 → 100644
View file @
42f38bf
const
express
=
require
(
'express'
);
const
app
=
express
();
const
port
=
3000
;
let
questions
=
[];
let
jobList
=
[];
app
.
get
(
'/'
,
(
req
,
res
,
next
)
=>
{
res
.
send
(
'hello world!'
);
});
app
.
get
(
'/getQuestions'
,
(
req
,
res
,
next
)
=>
{
/**
* 질문 폼
* 번호 질문내용 답1 답2 가중치1, 가중치2
*/
let
questionNums
=
[];
const
numOfQuestions
=
25
;
for
(
let
i
=
0
;
i
<
numOfQuestions
;
i
++
){
questionNums
[
i
]
=
i
;
}
// shuffle(questionNums);
questionNums
.
sort
(
function
()
{
return
Math
.
round
(
Math
.
random
())
-
0.5
});
questionNums
=
questionNums
.
slice
(
0
,
10
);
let
sendQuestions
=
[];
for
(
let
i
=
0
;
i
<
10
;
i
++
){
sendQuestions
.
push
(
questions
[
questionNums
[
i
]]);
}
res
.
send
(
sendQuestions
);
});
app
.
post
(
'/submit'
,
(
req
,
res
,
next
)
=>
{
const
{
answer
}
=
req
.
body
;
console
.
log
(
answer
);
const
answerArray
=
[];
let
score
=
50
;
/**
* 정답 폼
* 문항 번호 정답 고른것
*/
for
(
let
i
=
0
;
i
<
answerArray
.
length
;
i
++
){
if
(
answerArray
[
i
][
1
]
===
0
){
// 1번답 골랐을때
score
+=
questions
[
answerArray
[
i
]][
3
];
}
else
{
score
+=
questions
[
answerArray
[
i
]][
4
];
}
}
const
recommendedJob
=
jobList
[
score
%
jobList
.
length
];
res
.
send
(
recommendedJob
);
});
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Server is running at
${
port
}
`
);
});
\ No newline at end of file
Please
register
or
login
to post a comment