Spaces:
Sleeping
Sleeping
Create frontend/src/App.jsx
Browse files- frontend/src/App.jsx +23 -0
frontend/src/App.jsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useEffect, useState } from "react";
|
| 2 |
+
|
| 3 |
+
export default function App() {
|
| 4 |
+
const [apiMsg, setApiMsg] = useState("");
|
| 5 |
+
|
| 6 |
+
useEffect(() => {
|
| 7 |
+
fetch("/api/hello")
|
| 8 |
+
.then((r) => r.json())
|
| 9 |
+
.then((d) => setApiMsg(d.message))
|
| 10 |
+
.catch(() => setApiMsg("API not reachable yet"));
|
| 11 |
+
}, []);
|
| 12 |
+
|
| 13 |
+
return (
|
| 14 |
+
<div style={{ fontFamily: "system-ui", padding: 24, lineHeight: 1.5 }}>
|
| 15 |
+
<h1>React + FastAPI (Docker, HF Spaces)</h1>
|
| 16 |
+
<p>This is a plain starter page. Customize freely.</p>
|
| 17 |
+
|
| 18 |
+
<div style={{ marginTop: 16, padding: 12, border: "1px solid #ddd", borderRadius: 8 }}>
|
| 19 |
+
<strong>API says:</strong> {apiMsg}
|
| 20 |
+
</div>
|
| 21 |
+
</div>
|
| 22 |
+
);
|
| 23 |
+
}
|