# fastapi-demo **Repository Path**: sklh/fastapi-demo ## Basic Information - **Project Name**: fastapi-demo - **Description**: python 3.12 FastAPI - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-12 - **Last Updated**: 2025-09-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: Python, FastAPI ## README 1. 安装UV ```shell 存在系统Python: pip install uv 不存在系统Python 先安装uv: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" 再通过uv安装python: uv python install 3.12 参考: https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1 ``` 2. 生成uv环境 ```shell 复制.env.example为.env uv sync --locked uv run uvicorn main:app pre-commit install ``` 3. 启动 ```shell 测试环境: uvicorn main:app --reload 或者 fastapi dev 4. 同步包 ```shell uv sync ``` 5. 新增包 ```shell uv add python-dotenv ``` ## docker启动部署 ``` # 构建镜像 sudo docker build -t xlab-admin-service . # 运行容器 sudo docker run -d --name xlab-admin-service -p 8100:8000 xlab-admin-service ``` ### 开发注意点 1. 测试不要写到业务里面, 可以在tests/目录下面写测试文件 2. 本项目采用ruff和pywright进行代码检查, 问题没有解决的话无法提交 3. 日志请使用core.logger.Logger进行日志记录 4. 安装包请务必使用uv add 进行安装, 不要使用pip install