FastApi
4 人感兴趣 · 24 次引用
- 最新
- 推荐

FastAPI 快速开发 Web API 项目: 通过 SQLAlchemy 进行数据操作
本文将 SQLAlchemy 结合使用 FastAPI 实现了数据库的连接和操作,更多 ORM 操作数据库大同小异,如果学习过 Django 框架的同学本身也不陌生,不懂就查官方文档。优秀的框架总少不了优秀的文档,也少不了大量的使用者。

FastAPI 快速开发 Web API 项目: 连接 MySQL 数据库
本文总结了通过 MySQL 驱动连接 Python, 实现了一个 FastAPI 连接 MySQL 数据库的示例, 并结合代码结构设计了目录结构和实现了获取用户和增加用户的功能,今后会继续沿用这个示例写用户的登录和注册功能, 敬请期待。

FastAPI 快速开发 Web API 项目: 响应模型与错误处理
本文学习了什么是响应和响应模型,以及错误处理的含义,并了解了 HTTP 状态码以及它的含义。并利用 FastAPI 创建了一个响应模型,只返回待办事项列表中的 item ,而不返回其 id。最后,我们学习了错误和错误处理,让 Todo应用在发生查不到的情况返回 404 错误

FastAPI 快速开发 Web API 项目: 定义路径参数和查询参数
我们了解了什么是路径和查询参数以及如何在 FastAPI 中实现它们。然后,我们研究了如何通过限制数字和字符串值来对这些参数创建约束。我们还回顾了路径参数和查询参数之间的主要区别,并在 todo 应用中运用了展示了如何去使用路径参加和查询参数。

FastAPI 的路由介绍与使用
路由 Router 就像是一个流水线上的线长,协调生产,下达命令给不同的组长进行分工,然后执行基本的任务。路由器的工作目的是,在团队中工作时,您可能必须在团队成员(这里的团队负责人是队长)之间分配复杂性,这将有助于更快地完成项目。

FastApi-15- 文件上传 -3
前面我们已经学习了文件的上传,多个文件上传,以及文件对象的常用属性获取。但是实际开发中通常需要在上传文件后对文件进行保存,今天我们就一起来看看。

FastApi-13- 文件上传 -1
前面我们已经了解了 Form 表单,其多用于数据提交。今天我们一起来看下文件的上传,同样也需要使用到 Form 表单。


FastApi-10-Example
你可能注意到了,之前的 docs 中在 response 中的 Example Value 中是没有实例的,这个怎么做呢?

FastApi-12-Form 表单
相信你一定听过或者见过 HTMl 的 form 元素,这里所指的 Form 表单就是 FastApi 用来获取 HTML 中 form 元素的对象。





FastApi-07- 查询参数校验
前面我们已经了解了查询参数,但是实际开发中我们可能需要限定参数的类型,长度等其他属性。这个时候我们就需要对查询参数进行校验。




