-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
47 lines (42 loc) · 1.05 KB
/
App.js
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
41
42
43
44
45
46
47
import React, { useState } from 'react';
function PlacementForm() {
const [year, setyear] = useState('');
const [prediction, setPrediction] = useState('');
const handleSubmit = async (e) => {
e.preventDefault();
const response = await fetch('http://localhost:8000/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
year: parseInt(year),
}),
});
const data = await response.json();
setPrediction(data['the prediction is:']);
};
return (
<div>
<h1>Placement Predictor</h1>
<form onSubmit={handleSubmit}>
<div>
<label>year:</label>
<input
type="number"
value={year}
onChange={(e) => setyear(e.target.value)}
/>
</div>
<button type="submit">Predict</button>
</form>
{prediction && (
<div>
<h2>Prediction:</h2>
<p>{prediction}</p>
</div>
)}
</div>
);
}
export default PlacementForm;