摘要: 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 阅读(19) 评论(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 阅读(18) 评论(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 阅读(21) 评论(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 阅读(54) 评论(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 阅读(345) 评论(0) 推荐(0) 编辑