Add FastAPI backend and React frontend setup with initial routes and components

This commit is contained in:
2024-12-24 19:55:36 +01:00
parent 872fb54ecc
commit 42a447f12e
10 changed files with 114 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { useState, useEffect } from 'react'
function App() {
const [items, setItems] = useState([])
useEffect(() => {
fetch('http://localhost:8000/api/items')
.then(response => response.json())
.then(data => setItems(data))
}, [])
return (
<div className="App">
<h1>React + FastAPI Template</h1>
<ul>
{items.map((item, index) => (
<li key={index}>{item.name}</li>
))}
</ul>
</div>
)
}
export default App
+9
View File
@@ -0,0 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>
)