# fastapp **Repository Path**: arch-builder/fastapp ## Basic Information - **Project Name**: fastapp - **Description**: 基于 starlette 的 web demo - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-26 - **Last Updated**: 2026-02-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # fastapp 基于 starlette 的 web server demo。 ## Dependency ### 使用 fastapi 使用下面的命令安装依赖,带 fastapi-cli。 ```bash pip install fastapi[standard] ``` ### 不使用 fastapi 去掉 fastapi 后只需要安装以下依赖包: - python-multipart - pydantic - pyyaml - starlette - uvicorn > 注: > - 项目的配置文件可选其他形式,如果不用 yaml 格式,可以不需要 pyyaml。推荐使用 toml 作为配置文件的格式。 > - uvicorn 在 linux 系统中运行还需要安装 uvloop,在 windows 系统中不需要。 > - 如果需要使用长链接,还需要安装 websocket。 ## 结构 推荐目录结构: ```plaintext project_dir/ ├── config # 配置文件目录 │ ├── dev.yaml # 开发环境配置 │ └── prod.yaml # 生产环境配置 ├── src/fastapp │ ├── __init__.py │ ├── __version__.py # 定义版本号 │ ├── main.py # 入口 │ ├── config.py # 配置 │ ├── middelware/ # 中间件 │ │ ├── __init__.py # 定义基础组件或变量 │ │ ├── accesslog.py # 定义系统访问日志中间件 │ │ └── trace.py # 定义全局跟踪中间件 │ ├── model/ # 数据模型 │ │ ├── __init__.py # 定义基础数据模型 │ │ ├── const.py # 定义常量 │ │ └── ocr.py # 定义业务数据模型 │ ├── router/ # 路由,URI 终点处理函数 │ │ ├── __init__.py │ │ ├── users.py # 每个业务单独封装在模块中,各模块间不建议互相引用 │ │ └── items.py │ ├── service/ # 业务逻辑 │ │ ├── __init__.py │ │ └── user_service.py │ └── util/ # 工具函数 │ ├── __init__.py │ └── httputil.py ├── pyproject.toml # 构建配置 ├── tests/ # 测试 ├── requirements.txt └── README.md # 项目说明文档 ``` ## 两个分支 fastapi 适合快速启动服务验证,在工程化改造时遇到了不少困难,新建了 starlette 分支,代码中仅使用 starlette 提供的组件进行开发部署。 ## 运行 运行服务: ```bash $ pip install -e . $ python src/fastapp/main.py -c conf/dev.yaml # 或者使用脚本直接运行 $ fastapp -c conf/dev.yaml ``` ## 构建 使用 `build` 模块对项目进行发版部署 ```bash python -m build ``` > 注:**发版前要修改 `src/fastapp/__version__.py` 中的版本号**