Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Параметры Cookie | ||
|
||
Вы можете задать параметры Cookie таким же способом, как `Query` и `Path` параметры. | ||
|
||
## Импорт `Cookie` | ||
|
||
Сначала импортируйте `Cookie`: | ||
|
||
=== "Python 3.6 и выше" | ||
|
||
```Python hl_lines="3" | ||
{!> ../../../docs_src/cookie_params/tutorial001.py!} | ||
``` | ||
|
||
=== "Python 3.10 и выше" | ||
|
||
```Python hl_lines="1" | ||
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!} | ||
``` | ||
|
||
## Объявление параметров `Cookie` | ||
|
||
Затем объявляйте параметры cookie, используя ту же структуру, что и с `Path` и `Query`. | ||
|
||
Первое значение - это значение по умолчанию, вы можете передать все дополнительные параметры проверки или аннотации: | ||
|
||
=== "Python 3.6 и выше" | ||
|
||
```Python hl_lines="9" | ||
{!> ../../../docs_src/cookie_params/tutorial001.py!} | ||
``` | ||
|
||
=== "Python 3.10 и выше" | ||
|
||
```Python hl_lines="7" | ||
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!} | ||
``` | ||
|
||
!!! note "Технические детали" | ||
`Cookie` - это класс, родственный `Path` и `Query`. Он также наследуется от общего класса `Param`. | ||
|
||
Но помните, что когда вы импортируете `Query`, `Path`, `Cookie` и другое из `fastapi`, это фактически функции, которые возвращают специальные классы. | ||
|
||
!!! info "Дополнительная информация" | ||
Для объявления cookies, вам нужно использовать `Cookie`, иначе параметры будут интерпретированы как параметры запроса. | ||
|
||
## Резюме | ||
|
||
Объявляйте cookies с помощью `Cookie`, используя тот же общий шаблон, что и `Query`, и `Path`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /usr/bin/env bash | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
set -e | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters