Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2017110273
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
sdy
2021-06-03 03:07:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2b1c8496ecbb4b67ebce2d6f8623d9f62879e850
2b1c8496
1 parent
69a60910
Delete App.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
68 deletions
src/App.js
src/App.js
deleted
100644 → 0
View file @
69a6091
import
React
,
{
Fragment
,
useState
}
from
"react"
;
import
{
Client
}
from
"elasticsearch"
import
"./App.css"
;
function
App
()
{
const
[
answer
,
setAnswer
]
=
useState
(
''
);
const
[
inputValue
,
setInputValue
]
=
useState
(
''
);
const
client
=
new
Client
({
host
:
'http://localhost:9200'
});
const
onKeyUpHandler
=
async
(
event
)
=>
{
if
(
event
.
charCode
===
13
)
{
setInputValue
(
event
.
target
.
value
);
if
(
inputValue
!==
''
||
inputValue
!==
undefined
||
inputValue
.
length
!==
0
)
{
console
.
log
(
inputValue
);
try
{
const
result
=
await
client
.
search
({
index
:
"wiki-qna2"
,
body
:
{
query
:
{
match
:
{
"질문(원문, 하 난이도)"
:
inputValue
}
}
}
});
if
(
result
!==
null
||
result
!==
undefined
||
result
.
length
!==
0
)
{
setAnswer
(
result
.
hits
.
hits
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
}
}
const
showAnswer
=
(
answer
)
=>
{
return
(
<
div
>
<
b
>
{
answer
!==
undefined
?
answer
.
_source
.
정답
:
'loading ....'
}
<
/b
>
<
/div
>
)
}
return
(
<
div
className
=
"App"
>
<
header
className
=
"App-header"
>
<
Fragment
>
Ask
a
Question
<
input
size
=
"80"
onKeyPress
=
{
onKeyUpHandler
}
/
>
<
div
>
--
Answers
--
<
div
>
{
answer
===
''
?
" loading answer..."
:
showAnswer
(
answer
[
0
])}
<
/div
>
<
/div
>
<
/Fragment
>
<
/header
>
<
/div
>
);
}
export
default
App
;
Please
register
or
login
to post a comment