File size: 2,012 Bytes
51e559a 2367cc3 3a43ebf e92d5c0 51e559a 2367cc3 51e559a |
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 |
---
title: FastAPI + React Template
emoji: 💻
colorFrom: blue
colorTo: green
sdk: docker
app_port: 9481
pinned: false
license: mit
short_description: Template to vibe code a demo running on FastAPI + React
hf_oauth: true
---
# docker-space-fastapi-react
This repo is a template to run a FastAPI server hosting a React+Tailwind app in a Hugging Face Space.
Spaces are very well suited to vibe-code demos using Cursor, Lovable, Claude Code, etc. The hardest past is often to correctly configure the tooltip to make it work in the first place. This repo is intended to solve that.
## Getting started
The backend (Python + FastAPI) and the frontend (TS + React + Tailwind) are located respectively in the `backend/` and `frontend/` folder.
### Backend
To run the backend, you'll need `uv` and Python3.12 installed.
Install dependencies with:
```bash
uv venv
make install
```
And then run the backend server with:
```bash
make dev
```
For more details about backend development, check out [this README](./backend/README.md).
### Frontend
To run the frontend, you'll need nodeJS + pnpm installed.
Install dependencies with:
```bash
pnpm install
```
And then run the frontend app with:
```bash
pnpm dev
```
Once both parts are running, go to the frontend URL. You should see a green "Backend Online" message in the top-right corner. Note that this message is only visible in development mode. When running in a Space, it won't be shown to your end users.
For more details about frontend development, check out [this README](./frontend/README.md).
## Deploy
This repo is meant to be run in a [Docker Space](https://huggingface.co/docs/hub/spaces-sdks-docker).
Configuration should be automatically done if you clone the on the Hugging Face Hub.
If you want to run it on your own, you can use Docker:
```bash
docker build -t fastapi-react-space .
docker run -e HF_TOKEN -p 9481:9481 fastapi-react-space
```
Note that when running in Docker, the app runs in production mode without hot-reloading. |