Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ htmlcov/
# Environment
.env

# Pywrangler
python_modules
.venv-workers

# Editor
.idea/
.vscode/
Expand Down
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ No server infrastructure, no databases, no external dependencies.
| POST | `/ai/summary` | Summarise a completed tutoring session |
| GET | `/health` | Liveness check |

All endpoints return JSON and support CORS.

---

## Request / Response Examples
Expand Down Expand Up @@ -127,12 +125,12 @@ All endpoints return JSON and support CORS.
```
learnpilot/
├── src/
│ └── worker.py # Cloudflare Python Worker (all logic lives here)
│ └── worker.py # Cloudflare Python Worker (Main entry point)
├── tests/
│ └── test_worker.py # Unit tests (pytest, no Cloudflare runtime needed)
├── wrangler.toml # Cloudflare Workers deployment config
├── requirements-dev.txt # Dev/test dependencies (pytest only)
├── .env.example # Example environment variables for Wrangler CLI
│ └── test_worker.py # Unit tests (pytest)
├── wrangler.toml # Cloudflare Workers configuration
├── pyproject.toml # Python project configuration (uv)
├── uv.lock # Locked dependencies
├── LICENSE
└── README.md
```
Expand All @@ -143,20 +141,18 @@ learnpilot/

### Prerequisites

- [Node.js](https://nodejs.org/) ≥ 18 (for the Wrangler CLI)
- [uv](https://docs.astral.sh/uv/) (Python package manager)
- [Node.js](https://nodejs.org/) ≥ 18
- A [Cloudflare account](https://dash.cloudflare.com/sign-up) with Workers AI enabled

### Deploy

```bash
# Install Wrangler CLI
npm install -g wrangler

# Authenticate with Cloudflare
wrangler login
pywrangler login

# Deploy the worker to the edge
npx wrangler deploy
uv run pywrangler deploy
```

Wrangler will print the live URL, e.g.
Expand All @@ -165,7 +161,7 @@ Wrangler will print the live URL, e.g.
### Local Development

```bash
npx wrangler dev
uv run pywrangler dev
```

The worker starts on `http://localhost:8787`. All AI calls are proxied to
Expand All @@ -175,16 +171,11 @@ Cloudflare's remote AI service automatically during development.

## Running Tests

The tests use only the Python standard library and `pytest`. No Cloudflare
runtime is required – a minimal `Response` shim is injected before importing
`worker.py`.
The tests use `pytest` and `requests` to verify the worker's behavior against a running instance (local or remote).

```bash
# Install test dependencies
pip install -r requirements-dev.txt

# Run tests
pytest tests/ -v
uv run pytest tests/ -v
```

---
Expand All @@ -200,6 +191,9 @@ into the deployed worker.
| `CLOUDFLARE_ACCOUNT_ID` | Your Cloudflare account ID |
| `CLOUDFLARE_API_TOKEN` | API token with Workers AI permission |


Or you can simply log in with `pywrangler login` in your terminal as said above.

---

## License
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this with the uv.lock?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m probably doing something wrong, but without it, uv run pywrangler dev raises an error for me.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "learnpilot"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = []
[project.optional-dependencies]
test = [
"pytest",
"requests",
]
[tool.worker]
main = "src/worker.py"
compatibility_date = "2026-03-23"
compatibility_flags = ["python_workers"]
Loading