上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 49 下一页
摘要: import typing from fastapi import FastAPI, Response from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() ''' 响应模型 阅读全文
posted @ 2023-03-25 12:40 LeoShi2020 阅读(99) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI, Response from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() class User(BaseModel): 阅读全文
posted @ 2023-03-25 12:17 LeoShi2020 阅读(28) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI, Response from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() class User(BaseModel): 阅读全文
posted @ 2023-03-25 11:12 LeoShi2020 阅读(149) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI,status from pydantic import BaseModel app = FastAPI() ''' 响应状态代码 status ''' class User(BaseModel): username : str password 阅读全文
posted @ 2023-03-24 11:30 LeoShi2020 阅读(28) 评论(0) 推荐(0)
摘要: import random from fastapi import FastAPI from pydantic import Field, BaseModel import typing app = FastAPI() ''' 请求体的每一个字段需要单独校验 name 长度最少3位 price 不少 阅读全文
posted @ 2023-03-24 10:51 LeoShi2020 阅读(30) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI, Body from pydantic import BaseModel import typing app = FastAPI() ''' { "name": "book", "description": "python", "price": 阅读全文
posted @ 2023-03-24 00:43 LeoShi2020 阅读(30) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI,Body app =FastAPI() ''' 使用方法同Path Query ''' @app.post("/login") def login( name :str = Body(min_length=3), age:int = Body( 阅读全文
posted @ 2023-03-24 00:17 LeoShi2020 阅读(66) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI, Body from pydantic import BaseModel app = FastAPI() ''' 使用Body接收请求体数据 { "user": { "username": "Tom", "password": "1234657 阅读全文
posted @ 2023-03-24 00:05 LeoShi2020 阅读(381) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() ''' 多个请求体 { "user": { "username": "string", "password": "string" }, "item": 阅读全文
posted @ 2023-03-23 23:46 LeoShi2020 阅读(35) 评论(0) 推荐(0)
摘要: from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() ''' 创建继承BaseModel的类,定义模型user 路径函数中定义形参user,类型为User 通过对象user的属性获取字段的值 客户端使用P 阅读全文
posted @ 2023-03-23 23:29 LeoShi2020 阅读(114) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 49 下一页