Skip to content

Commit 7860bb3

Browse files
committed
Add FastAPI todobackend.com app example.
1 parent affcbff commit 7860bb3

8 files changed

Lines changed: 1847 additions & 0 deletions

File tree

fastapi-todo/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# FastAPI Todo Backend
2+
3+
A Python FastAPI implementation of the [Todo-Backend](https://todobackend.com) spec, running on Cloudflare Workers with D1 for storage.
4+
5+
## Development
6+
7+
Initialize the local D1 database and start the dev server:
8+
9+
```sh
10+
uv run pywrangler d1 execute todos --local --file db_init.sql
11+
uv run pywrangler dev
12+
```
13+
14+
## Testing with the Todo-Backend spec runner
15+
16+
Start the dev server, then open the spec runner pointing at your local instance:
17+
18+
```
19+
https://todobackend.com/specs/index.html?http://localhost:8787/todos
20+
```
21+
22+
You can also use the Todo-Backend client app:
23+
24+
```
25+
https://todobackend.com/client/index.html?http://localhost:8787/todos
26+
```
27+
28+
## API
29+
30+
| Method | Path | Description |
31+
| -------- | ---------------- | ------------------ |
32+
| `GET` | `/todos` | List all todos |
33+
| `POST` | `/todos` | Create a todo |
34+
| `DELETE` | `/todos` | Delete all todos |
35+
| `GET` | `/todos/{id}` | Get a single todo |
36+
| `PATCH` | `/todos/{id}` | Update a todo |
37+
| `DELETE` | `/todos/{id}` | Delete a todo |

fastapi-todo/db_init.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE IF NOT EXISTS todos (
2+
id TEXT PRIMARY KEY,
3+
title TEXT NOT NULL DEFAULT '',
4+
completed INTEGER NOT NULL DEFAULT 0,
5+
"order" INTEGER
6+
);

0 commit comments

Comments
 (0)