FastAPI: 请求体基础(6) Posted on 2021-10-01 | In FastAPI | | 这个不多说,就是客户端发送给 API 的数据。通过Pydantic来声明请求体。 12345678910class Book(BaseModel): name: str price: float description: Optional[str] = Noneapp = FastAPI()@app.post('/books/')def root(book: Book): return book 欢迎您扫一扫上面的微信公众号,订阅我的博客! 分享创造价值,您的支持将鼓励我继续前行! Donate WeChat Pay Alipay Post author: 唐胡璐 Post link: http://izheyi.com/2021/10/01/FastAPI-请求体基础(6)/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.