Giter VIP home page Giter VIP logo

fast-api-template's Introduction

fast-api-template

Python FastAPI

1.项目介绍

项目是基于FastAPI 学习使用FastAPI框架,并搭建一个项目模板,方便后续其他新项目可以直接使用,但愿该项目能为想学习、想使用FastApi的开发人员提供帮助。

@提示: 由于本人工作中常用的语言是PHP和Go,所以框架中的编码规范,并没有严格按照Python官方指定的规范,特别是变量名和函数名~

2.目录结构

@注: 下面目录仅供参考,在整个项目未开发结束,会有部分调整。

├── app
│   ├── __init__.py
│   ├── config  # 配置相关
│   │   └── __init__.py
│   ├── constant  # 常量相关
│   │   └── __init__.py
│   ├── dao # 封装查询数据的方法
│   │   └── __init__.py
│   ├── dependencies  # 封装被依赖函数
│   │   └── __init__.py
│   ├── errors  # 异常处理
│   │   └── __init__.py
│   ├── middleware # 中间件
│   │   └── __init__.py
│   ├── models # 数据模型文件,和表结构对应
│   │   └── __init__.py
│   ├── router # 路由也可以理解controller
│   │   ├── __init__.py
│   │   ├── admin_router.py # 后台接口
│   │   └── demo_router.py # 演示接口
│   ├── types # 声明入参和出参对应的Pydantic模型
│   │   ├── __init__.py
│   │   ├── request # 入参模型
│   │   └── response # 出参模型
│   ├── service # 就具体业务实现逻辑
│   │   ├── __init__.py
│   └── utils # 工具类
│       ├── __init__.py
│       └── str_util.py
├── requirements.txt #依赖文件
├── README.md  #项目介绍
├── main.py # 入口文件
└── tests # 单元测试目录
    ├── __init__.py
    └── local_test.py

3.项目启动

3.1 安装依赖

➜ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

3.2 启动命令

# xxx/xxx/fast-api-template下,使用uvicorn启动
➜ uvicorn main:server
INFO:     Started server process [36375]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

# 使用python
➜  python main.py
INFO:     Started server process [36468]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

4.项目状态

持续学习开发中...

5.项目历程

fast-api-template's People

Contributors

52lu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.