Skip to content

Commit

Permalink
Use Hyper http server.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmrigney committed Dec 14, 2022
1 parent edfa585 commit 63448e2
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 64 deletions.
15 changes: 10 additions & 5 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export function App() {
const [response, setResponse] = React.useState<string>();
const [error, setError] = React.useState<Error>();

const fetchAndDisplayResponse = async () => {
const fetchAndDisplayResponse = (endpoint: string) => async () => {
try {
const result = await fetch("http://localhost:1234/hello", {
const result = await fetch(`http://localhost:1234${endpoint}`, {
method: "POST",
body: 'Hello from Wasm',
});
Expand All @@ -32,9 +32,14 @@ export function App() {
response will appear in the textarea.
</Typography>
<Stack direction="row" alignItems="start" spacing={2} sx={{ mt: 4 }}>
<Button variant="contained" onClick={fetchAndDisplayResponse}>
Call backend
</Button>
<Stack spacing={2}>
<Button variant="contained" onClick={fetchAndDisplayResponse('/echo')}>
Echo From Backend
</Button>
<Button variant="contained" onClick={fetchAndDisplayResponse('/echo/reversed')}>
Reverse From Backend
</Button>
</Stack>

<TextField
label="Backend response"
Expand Down
Loading

0 comments on commit 63448e2

Please sign in to comment.