fastapi openapi

[FastAPI-13]pydantic请求体接收数据

from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() ''' 创建继承BaseModel的类,定义模型user 路径函数中定义形参user,类型为User 通过对象user的属性获取字段的值 客户端使用P ......
pydantic FastAPI 数据 13

[FastAPI-11]Query参数校验

import typing from fastapi import FastAPI, Query app = FastAPI() ''' 查询参数使用Query校验 类似路由转换使用Path校验 物品名称最小3位,最大10位 default=None 参数为可选项,否则为必选项 default=.. ......
参数 FastAPI Query 11

[FastAPI-10]查询参数多个相同的值

from fastapi import FastAPI, Query import typing app = FastAPI() ''' 查询多个参数值相同 ''' @app.get("/books") def books(book_id: typing.List[int] = Query()): ......
多个 参数 FastAPI 10

[FastAPI-09]查询参数默认值-Python函数默认值

from fastapi import FastAPI app = FastAPI() BOOKS = [ {"id": i, "title": f"book{i}"} for i in range(1, 11) ] ''' 查询参数的默认值 ''' @app.get("/books") # 默认为 ......
函数 参数 FastAPI Python 09

[FastAPI-08]Path校验

from fastapi import FastAPI,Path app = FastAPI() # Path校验 ''' 限制接口输入的数字大小限制 100-1000 限制字符串输入的字符数量 3-8位 ''' @app.get("/number/{num}") def number(num:in ......
FastAPI Path 08

[FastAPI-07]路径参数-枚举

from enum import Enum from fastapi import FastAPI app = FastAPI() # 路径参数枚举值 ''' 编程语言三种分类:python java go ''' # 继承str 枚举Enum class LangName(str, Enum): ......
路径 参数 FastAPI 07

[FastAPI-06]路径转换器

from fastapi import FastAPI app= FastAPI() # 路径转换器 ''' - str 字符串 - int 数字 - float 浮点 - uuid 返回python中的uuid.UUID - path 文件路径包含多个/ ''' @app.get("/books/ ......
转换器 路径 FastAPI 06

[FastAPI-05]OpenAPI接口信息

![](https://img2023.cnblogs.com/blog/1940615/202303/1940615-20230323090712489-1952166291.png) ......
接口 FastAPI OpenAPI 信息 05

[FastAPI-04]查询参数-分页

from fastapi import FastAPI BOOKS = [ {"id": 1, "title": "book1"}, {"id": 2, "title": "book2"}, {"id": 3, "title": "book3"}, {"id": 4, "title": "book4 ......
参数 FastAPI 04

fastapi多线程非阻塞启动

1 问题描述 我在run.py文件下的主函数如下所示: import uvicorn from fastapi import FastAPI app = FastAPI( title="chatglm", description="开源版的chatglm接口", version="1.0.0", ) ......
线程 fastapi

[FastAPI-02]动态静态路由

from fastapi import FastAPI app= FastAPI() # 静态路由模式 @app.get("/login") def login(): return {"msg":"Welcome CoCo Login"} @app.get("/books/{number}") # ......
路由 静态 FastAPI 动态 02

[FastAPI-03]动态静态路由顺序的问题-静态路由先执行

from fastapi import FastAPI app= FastAPI() # 静态路由优先级高于动态路由 # 必须写在动态路由的前面 @app.get("/books/most_populer") def books_most_populer(): return {"This Book ......
路由 静态 顺序 FastAPI 动态
共222篇  :8/8页 首页上一页8下一页尾页