Spaces:
Sleeping
Sleeping
File size: 2,276 Bytes
02a9316 8765030 |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import { Button, Grid, TextField } from "@mui/material";
import { useState } from "react";
import "./App.css";
function App() {
const [message, setMessage] = useState("");
const [wordOne, setWordOne] = useState("");
const onChangeWordOne = (event) => {
const newWord = event.target.value;
console.log("Word One: ", newWord);
setWordOne(newWord);
};
const onPressButton = () => {
setMessage("Pau chupapijas");
// console.log("Word One: ", wordOne);
// const url = "http://127.0.0.1:8000/test";
const url = "https://abadesalex-emb-rep.hf.space/test";
const dataToSend = JSON.stringify({ message: wordOne });
fetch(url, {
method: "POST", // Specifying the method
headers: {
"Content-Type": "application/json",
},
body: dataToSend, // Data must be a stringified JSON
})
.then((response) => response.json())
.then((data) => setMessage(data.Hello))
.catch((error) => console.error("Error:", error));
};
return (
<>
<Grid container mt={2} mr={2} ml={2} textAlign={"center"} spacing={2}>
<Grid item xs={3}>
<TextField
id="word-one"
label="Word 1"
variant="outlined"
onChange={onChangeWordOne}
fullWidth
/>
</Grid>
<Grid item xs={3}>
<TextField
id="word-two"
label="Word 2"
variant="outlined"
fullWidth
/>
</Grid>
<Grid item xs={3}>
<Button
variant="contained"
color="primary"
fullWidth
sx={{ height: "100%" }}
onClick={onPressButton}
>
Compare Embedding
</Button>
</Grid>
</Grid>
<Grid item textAlign={"center"}>
<h1>{message}</h1>
</Grid>
</>
);
}
export default App;
<div>
<input
type="text"
value={wordOne}
onChange={onChangeWordOne}
placeholder="First Word"
/>
<input
type="text"
value={wordTwo}
onChange={onChangeWordTwo}
placeholder="Second Word"
/>
<button onClick={onPressButton}>Submit</button>
<p>{message}</p>
</div> |