hyf-backend/README.md

31 lines
896 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 启动项目(本地)
1. 准备环境
- 推荐 Python 3.11+
- 创建并激活虚拟环境:`python3 -m venv .venv && source .venv/bin/activate`
- 依赖安装:`pip install -r requirements.txt`(若 requirements.txt 为 UTF-16需要先转 UTF-8
2. 配置数据库
- 确保本地 MySQL 运行,并创建数据库/账号(例):
```sql
CREATE DATABASE allm DEFAULT CHARACTER SET utf8mb4;
ALTER USER 'root'@'localhost' IDENTIFIED BY '13813746735';
GRANT ALL PRIVILEGES ON allm.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
```
- 启动前设置环境变量:
```bash
export DATABASE_URL=""
```
3. 迁移(首次必跑)
```bash
python -m alembic upgrade head
```
4. 启动服务
```bash
# 启动项目命令
python3 -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload
```