Skip to content
Public template

About

FastAPI template for LeafCloud. A small Python API with a Dockerfile, health check and tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FastAPI — API template

A small Python API with a Dockerfile, a health check and tests, ready to deploy on LeafCloud.

All templates · Server apps with a Dockerfile

What's inside

  • app/main.py: the API. GET /, GET /healthz, GET /items, GET /items/{id}, and interactive docs at /docs.
  • Dockerfile: installs the exact versions from uv.lock, runs as an unprivileged user, listens on $PORT (default 8080) on 0.0.0.0.
  • tests/: a few tests with FastAPI's test client.

Run it locally

Install uv, then:

git clone https://github.com/leafcloud-in/template-fastapi.git
cd template-fastapi
uv sync
uv run fastapi dev app/main.py

Open http://127.0.0.1:8000/docs. Run the tests with uv run pytest.

To try the container the way LeafCloud runs it:

docker build -t template-fastapi .
docker run --rm -p 8080:8080 template-fastapi
curl http://127.0.0.1:8080/healthz

Deploy on LeafCloud

  1. Choose Use this template on GitHub to make your own copy.
  2. In the LeafCloud dashboard, open Settings → GitHub, install the LeafCloud GitHub App on your account or organization, and pick your repository.
  3. LeafCloud finds the Dockerfile and opens a pull request that adds one workflow file. Merge it: every push to the branch builds the image in your GitHub Actions and deploys it.

Port: 8080. Health path: /healthz. Set your own environment variables and secrets in the app's settings.

Make it yours

Replace the sample ITEMS in app/main.py with your own routes and storage, add dependencies with uv add <package>, and keep /healthz answering 200 so deploys can tell the app is up.

License

MIT

About

FastAPI template for LeafCloud. A small Python API with a Dockerfile, health check and tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages