mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-25 11:19:15 -05:00
📝 Improve explanation of request bodies
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
To declare a request body, you use <a href="https://pydantic-docs.helpmanual.io/" target="_blank">Pydantic</a> models with all their power and benefits.
|
||||
When you need to send data from a client (let's say, a browser) to your API, you send it as a **request body**.
|
||||
|
||||
A **request** body is data sent by the client to your API. A **response** body is the data your API sends to the client.
|
||||
|
||||
Your API almost always has to send a **response** body. But clients don't necessarily need to send **request** bodies all the time.
|
||||
|
||||
To declare a **request** body, you use <a href="https://pydantic-docs.helpmanual.io/" target="_blank">Pydantic</a> models with all their power and benefits.
|
||||
|
||||
!!! info
|
||||
You cannot send a request body using a `GET` operation (HTTP method).
|
||||
|
||||
To send data, you have to use one of: `POST` (the more common), `PUT`, `DELETE` or `PATCH`.
|
||||
|
||||
## Import Pydantic's `BaseModel`
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ pip install fastapi[all]
|
||||
|
||||
This is what you would probably do once you want to deploy your application to production:
|
||||
|
||||
```bash
|
||||
```
|
||||
pip install fastapi
|
||||
```
|
||||
|
||||
Also install `uvicorn` to work as the server:
|
||||
|
||||
```bash
|
||||
```
|
||||
pip install uvicorn
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user