fix:api
FastApi 模块工程模板。
本仓库 FastApiModuleTemplate 是 FastApi 应用 的 子模块工程模板。 该工程可以 独立开发,独立运行,并在必要时,可以由 FastApi 应用 引用集成。
. ├── fast_api_module_template # 子模块名 │ ├── dependencies # 依赖项模块 │ │ ├── __init__.py │ │ ├── authorization.py # 授权依赖 │ ├── docs # 相关文档与手册 │ │ ├── manual.md # 手册文档 │ ├── items # 数据结构模块 │ │ ├── __init__.py │ │ ├── user.py # 用户数据结构 │ ├── logs # 日志文件 │ │ ├── debug.log # 调试日志 │ ├── routers # 路由模块 │ │ ├── __init__.py │ │ ├── hello_world.py # hello_world 子路由 │ ├── statics # 静态资源文件 │ │ ├── icons # 图标 │ │ │ ├── favicon.svg # favicon 图标 │ ├── templates # HTML 模板文件 │ │ ├── index.html # index 网页模板 │ └── utils # 第三方、工具、常量、异常等公用工具模块 │ │ ├── __init__.py │ │ └── log_util.py # 日志工具 │ ├── __init__.py │ ├── .gitignore # 启停或其他脚本 │ ├── main.py # 启动项目入口文件 │ ├── readme.md # 项目说明文档 │ ├── requirements.txt # 项目运行环境依赖包 │ ├── restart.sh # 重启脚本 │ ├── start.sh # 启动脚本 │ ├── stop.sh # 停止脚本
from fastapi import APIRouter hello_world_router = APIRouter() @hello_world_router.get("/") async def do_hello_world(): return "Hello World!"
from .routers import hello_world hello_world_app.include_router(hello_world.hello_world_router)
cd .. uvicorn FastApiModuleTemplate.app:hello_world_app --host 0.0.0.0 --port 8080 --reload
在 Python 开发 时,请使用 相对引用。
FastApi 使用 APIRouter 子路由构建路径
https://fastapi.org.cn/learn/
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
FastApiModuleTemplate
1.简介
FastApi 模块工程模板。
2.使用说明
本仓库 FastApiModuleTemplate 是 FastApi 应用 的 子模块工程模板。 该工程可以 独立开发,独立运行,并在必要时,可以由 FastApi 应用 引用集成。
2.1.工程目录
2.2.启动步骤
3.注意事项
在 Python 开发 时,请使用 相对引用。
FastApi 使用 APIRouter 子路由构建路径
参考文档