A FastAPI-based algorithm flow management system with Tortoise ORM and Aerich for database migrations
Project description
FastAPI 模板
一个用于构建 FastAPI 应用程序的模板项目,包含 Tortoise ORM 和 Aerich 用于数据库迁移。
特性
- FastAPI、Tortoise ORM、Aerich 和 Pydantic 构建
- Docker Compose 快速部署
- Github Actions CI/CD
使用
安装
-
克隆仓库:
git clone https://github.com/chenxingyuu/fastapi_template.git cd fastapi-template
-
创建并激活虚拟环境:
python -m venv venv source venv/bin/activate # 在 Windows 上使用 `venv\Scripts\activate`
-
安装依赖项:
pip install -r requirements.txt
迁移
-
初始化 Aerich:
make init -
初始化数据库:
make init-db -
创建并应用迁移:
make migrate make upgrade
-
回滚迁移:
make downgrade
运行
-
设置配置文件路径:
在 Linux 或 macOS 上:
export CONFIG_FILE_PATH=/path/to/your/config.ini
在 Windows 上:
set CONFIG_FILE_PATH=C:\path\to\your\config.ini
-
启动 FastAPI 应用程序:
uvicorn app.main:app --reload
-
访问应用程序:
打开浏览器并访问
http://127.0.0.1:8000。
使用 Docker
-
构建 Docker 镜像:
docker build -t algo-flow:0.1.0 .
-
运行 Docker 容器:
docker run -d -p 8000:8000 --name algo-flow-api algo-flow:0.1.0
-
访问应用程序:
打开浏览器并访问
http://127.0.0.1:8000。
使用 Docker Compose
-
启动服务:
docker-compose up -d
-
访问应用程序:
打开浏览器并访问
http://127.0.0.1:8000。 -
停止服务:
docker-compose down
开发
-
安装 pre-commit 钩子:
pre-commit install -
运行测试:
# 运行所有测试 pytest -v # 如果你想生成覆盖率报告,可以使用以下命令: pytest --cov-report=html -v
-
检查代码并格式化:
pre-commit run --all-file
-
在开发模式下运行应用程序:
uvicorn app.main:app --reload
配置
配置通过 config.ini 文件进行管理。在运行应用程序之前,请确保将 CONFIG_FILE_PATH 环境变量设置为指向你的配置文件。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file algoflow-0.1.0.tar.gz.
File metadata
- Download URL: algoflow-0.1.0.tar.gz
- Upload date:
- Size: 157.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92ef92eae9a62ae9a4d9ec64c4ceb3d27ba6fe7c4ef151fcb377cb57eddf25f0
|
|
| MD5 |
3f970d5e6867588ac3a3d582db3e8733
|
|
| BLAKE2b-256 |
13604ef5669ea015908d2e27d7954834958ea0543caf57027e4c9bb6d9d5b2f4
|
File details
Details for the file algoflow-0.1.0-py3-none-any.whl.
File metadata
- Download URL: algoflow-0.1.0-py3-none-any.whl
- Upload date:
- Size: 133.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec1e6857c44d6d501a1a8a9d056f5e80b7b050953e0cd658224ad19e69e88037
|
|
| MD5 |
cca28d3454c53bca2887a9f15d0bd394
|
|
| BLAKE2b-256 |
51c2119a321b429253deb3c42bf3e8e6c8d1aefdf20b7260ae5c76fc872d0921
|