上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 49 下一页
摘要: # 查找文件路径 find / -name docs.py vi docs.py # swagger_js_url: str = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui-bundle.js", swagger_js_url 阅读全文
posted @ 2023-03-23 22:38 LeoShi2020 阅读(280) 评论(1) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI,Header app = FastAPI() @app.get("/books") # 接收多个token def books(token :typing.List[str] = Header()): return 阅读全文
posted @ 2023-03-23 22:07 LeoShi2020 阅读(22) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, Query app = FastAPI() ''' 查询参数使用Query校验 类似路由转换使用Path校验 物品名称最小3位,最大10位 default=None 参数为可选项,否则为必选项 default=.. 阅读全文
posted @ 2023-03-23 21:06 LeoShi2020 阅读(54) 评论(0) 推荐(0) 编辑
摘要: from fastapi import FastAPI, Query import typing app = FastAPI() ''' 查询多个参数值相同 ''' @app.get("/books") def books(book_id: typing.List[int] = Query()): 阅读全文
posted @ 2023-03-23 20:36 LeoShi2020 阅读(25) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI app = FastAPI() BOOKS = [ {"id": i, "title": f"book{i}"} for i in range(1, 11) ] ''' 查询参数的默认值 ''' @app.get(" 阅读全文
posted @ 2023-03-23 17:23 LeoShi2020 阅读(85) 评论(0) 推荐(0) 编辑
摘要: from fastapi import FastAPI,Path app = FastAPI() # Path校验 ''' 限制接口输入的数字大小限制 100-1000 限制字符串输入的字符数量 3-8位 ''' # deprecated 即将废弃 # include_in_schema 隐藏接口 阅读全文
posted @ 2023-03-23 16:40 LeoShi2020 阅读(22) 评论(0) 推荐(0) 编辑
摘要: from enum import Enum from fastapi import FastAPI app = FastAPI() # 路径参数枚举值 ''' 编程语言三种分类:python java go ''' # 继承str 枚举Enum class LangName(str, Enum): 阅读全文
posted @ 2023-03-23 12:35 LeoShi2020 阅读(119) 评论(0) 推荐(0) 编辑
摘要: from fastapi import FastAPI app= FastAPI() # 路径转换器 ''' - str 字符串 - int 数字 - float 浮点 - uuid 返回python中的uuid.UUID - path 文件路径包含多个/ ''' @app.get("/books/ 阅读全文
posted @ 2023-03-23 10:14 LeoShi2020 阅读(32) 评论(0) 推荐(0) 编辑
摘要: ![](https://img2023.cnblogs.com/blog/1940615/202303/1940615-20230323090712489-1952166291.png) 阅读全文
posted @ 2023-03-23 09:07 LeoShi2020 阅读(20) 评论(0) 推荐(0) 编辑
摘要: from fastapi import FastAPI BOOKS = [ {"id": 1, "title": "book1"}, {"id": 2, "title": "book2"}, {"id": 3, "title": "book3"}, {"id": 4, "title": "book4 阅读全文
posted @ 2023-03-22 09:09 LeoShi2020 阅读(314) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 49 下一页