-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
40 lines (33 loc) · 1.03 KB
/
App.js
File metadata and controls
40 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// src/App.js
import React, { useState } from 'react';
import FileUploader from './components/FileUploader';
import Quiz from './components/Quiz';
function App() {
const [text, setText] = useState('');
const [problems, setProblems] = useState([]);
const [mode, setMode] = useState('upload'); // 'upload', 'quiz'
const handleTextReceived = async (newText) => {
setText(newText);
// 문제 생성 요청
const res = await fetch('http://localhost:5000/generate-quiz', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: newText }),
});
const data = await res.json();
setProblems(data.problems);
setMode('quiz');
};
return (
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '20px' }}>
{mode === 'upload' && (
<>
<h1>문제 생성기</h1>
<FileUploader onTextReady={handleTextReceived} />
</>
)}
{mode === 'quiz' && <Quiz problems={problems} />}
</div>
);
}
export default App;