快速开始
本文档将帮助你快速启动 HEI FastAPI 项目。
环境要求
| 软件 | 版本要求 | 说明 |
|---|---|---|
| Python | 3.13+ | 项目使用 Python 3.13+ 语法特性 |
| MySQL | 8.0+ | 主数据库 |
| Redis | 6.0+ | 缓存及会话存储 |
5 分钟快速启动
1. 克隆项目
bash
git clone https://gitee.com/jiangbyte/hei-fastapi.git
cd hei-fastapi2. 创建虚拟环境
bash
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows3. 安装依赖
bash
pip install -r requirements.txt4. 创建数据库
sql
CREATE DATABASE IF NOT EXISTS hei_data DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;执行 SQL 脚本初始化数据库:
bash
mysql -u root -p hei_data < scripts/sqls/hei_ddl.sql5. 修改配置
编辑 .env 文件,修改数据库和 Redis 连接信息:
env
DB__HOST=localhost
DB__PORT=3306
DB__USER=root
DB__PASSWORD=your_password
DB__DATABASE=hei_data
REDIS__HOST=localhost
REDIS__PORT=6379
REDIS__PASSWORD=your_password6. 启动服务
bash
python main.py7. 访问系统
| 服务 | 地址 | 说明 |
|---|---|---|
| 后端服务 | http://localhost:8081 | 默认端口 |
| API 文档 | http://localhost:8081/docs | Swagger UI |
默认配置
- Token Header:
Authorization - Token 有效期: 30 天
- 默认端口: 8081