|
23 | 23 | </a>
|
24 | 24 | </div>
|
25 | 25 |
|
26 |
| -# Python FastAPI Template |
27 |
| - |
28 |
| -A template for a Python FastAPI service: |
29 |
| -- [x] [uv](https://docs.astral.sh/uv/getting-started/) for dependency management |
30 |
| -- [x] [FastAPI](https://fastapi.tiangolo.com/) for building the API |
31 |
| -- [x] [Devcontainer](https://code.visualstudio.com/docs/devcontainers/tutorial) for development environment |
32 |
| -- [x] [Docker](https://www.docker.com/) for containerization |
33 |
| -- [x] [Black](https://black.readthedocs.io/) & [isort](https://pycqa.github.io/isort/) for code formatting |
34 |
| -- [x] [pre-commit](https://pre-commit.com/) for code quality checks |
35 |
| -- [x] [Github Actions](https://github.com/features/actions) for CI/CD |
36 |
| -- [x] [pytest](https://docs.pytest.org/) for testing |
37 |
| - |
38 |
| -## Build and run locally |
39 |
| - |
40 |
| -Install `uv` and `python3.11` |
41 |
| -``` |
42 |
| -curl -LsSf https://astral.sh/uv/install.sh | sh |
43 |
| -uv python install 3.11 |
44 |
| -``` |
45 |
| - |
46 |
| -Then install dependencies |
47 |
| -``` |
48 |
| -uv sync --frozen |
49 |
| -``` |
50 |
| - |
51 |
| -Run locally |
52 |
| -``` |
53 |
| -uv run uvicorn app.main:app --port 8000 --reload |
54 |
| -``` |
55 |
| - |
56 |
| -## Run tests |
57 |
| -``` |
58 |
| -uv run pytest |
59 |
| -``` |
60 |
| - |
61 |
| -## Build and run using Docker |
62 |
| - |
63 |
| -``` |
64 |
| -docker build -t app . |
65 |
| -docker run -p 8000:8000 -it app |
66 |
| -``` |
67 |
| - |
68 |
| -### Notes |
69 |
| -- If you face an issue with **git ssh access** while pushing new changes, run `ssh-add $HOME/.ssh/<your ssh key>` in terminal outside the devcontainer. |
70 |
| - |
71 |
| -- If you face an issue during **devcontainer build**, make sure the repo is marked as trusted in VSCode. Check `Source Control` tab in the sidebar to mark the repo safe, then rebuild the devcontainer. |
72 |
| - |
73 |
| -## Sample CRUD API |
74 |
| - |
75 |
| -The `/v1` directory contains a sample API router demonstrating basic CRUD operations for users: |
76 |
| - |
77 | 26 | - Endpoints: Create, Read, Update, Delete users
|
78 | 27 | - Router setup: `app/v1/routers/base.py` and `app/v1/routers/users.py`
|
79 | 28 | - User model: `app/v1/models/user.py`
|
80 | 29 | - User management: `app/v1/services/user/user_manager.py`
|
81 |
| - |
82 |
| -Use the samples as a starting point for your own API endpoints. View available endpoints at `http://localhost:8000/docs`. |
0 commit comments