1 Star 0 Fork 0

学习教程 / fastapi-framework-study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

FASTAPI

FastAPI framework, high performance, easy to learn, fast to code, ready for production

特色:自动补全

一个完整的框架需要解决的问题。

  1. 接收参数,参数的序列化与反序列化的处理,参数的校验
  2. service层的处理
  3. 数据库的插入操作
  4. 全局异常处理

Documentation: https://fastapi.tiangolo.com

中文文档:https://fastapi.tiangolo.com/zh/

Source Code: https://github.com/tiangolo/fastapi

组件

技术 说明 官网
fastapi web server https://fastapi.tiangolo.com/
uvicorn web容器 https://www.uvicorn.org/
PySnooper 调试,展示调用详情 https://github.com/cool-RR/PySnooper
ujson an ultra fast JSON encoder and decoder written in pure C with bindings for Python 3.7+. https://github.com/ultrajson/ultrajson
Pydantic 基于标准的 Python 3.6 类型声明 https://pydantic-docs.helpmanual.io/

安装fastapi

pip3 install -r requirements.txt 
pip install fastapi
pip install uvicorn

运行程序

下面这种非常规启动程序与java的war包丢在tomcat里面一样。本质上差不多。而且效果可能更好,可以自动热重启。

uvicorn main:app --reload

热重启

uvicorn main:app --reload

main方法运行

下面这种与上面没有本质区别。

    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

FastAPI 开始安装(创建第一个例子)多种运行方式 官网提供这种运行方式

自带文档

Swagger UI : http://127.0.0.1:8000/docs#/

或者

ReDoc : http://127.0.0.1:8000/redoc

openapi:http://127.0.0.1:8000/openapi.json

img.png

img_1.png

其他成熟fastapi项目学习

  1. https://gitee.com/likeadmin/likeadmin_python

空文件

简介

python 异步高性能框架 fastapi-framework-study 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/eric-tutorial/fastapi-framework-study.git
git@gitee.com:eric-tutorial/fastapi-framework-study.git
eric-tutorial
fastapi-framework-study
fastapi-framework-study
master

搜索帮助