Browse Source

Merge branch 'master' into kor-security-intro

pull/5612/head
Sebastián Ramírez 2 years ago
committed by GitHub
parent
commit
ffe4eb4be5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      .github/DISCUSSION_TEMPLATE/questions.yml
  2. 12
      .github/ISSUE_TEMPLATE/config.yml
  3. 181
      .github/ISSUE_TEMPLATE/feature-request.yml
  4. 22
      .github/ISSUE_TEMPLATE/privileged.yml
  5. 419
      .github/actions/notify-translations/app/main.py
  6. 21
      .github/actions/notify-translations/app/translations.yml
  7. 214
      .github/actions/people/app/main.py
  8. 7
      .github/actions/watch-previews/Dockerfile
  9. 10
      .github/actions/watch-previews/action.yml
  10. 101
      .github/actions/watch-previews/app/main.py
  11. 103
      .github/workflows/build-docs.yml
  12. 29
      .github/workflows/deploy-docs.yml
  13. 5
      .github/workflows/issue-manager.yml
  14. 3
      .github/workflows/label-approved.yml
  15. 4
      .github/workflows/latest-changes.yml
  16. 3
      .github/workflows/notify-translations.yml
  17. 8
      .github/workflows/people.yml
  18. 11
      .github/workflows/publish.yml
  19. 5
      .github/workflows/smokeshow.yml
  20. 62
      .github/workflows/test.yml
  21. 2
      .gitignore
  22. 21
      .pre-commit-config.yaml
  23. 17
      README.md
  24. 466
      docs/az/docs/index.md
  25. 145
      docs/az/mkdocs.yml
  26. 1
      docs/de/docs/index.md
  27. 147
      docs/de/mkdocs.yml
  28. 240
      docs/em/docs/advanced/additional-responses.md
  29. 37
      docs/em/docs/advanced/additional-status-codes.md
  30. 70
      docs/em/docs/advanced/advanced-dependencies.md
  31. 162
      docs/em/docs/advanced/async-sql-databases.md
  32. 92
      docs/em/docs/advanced/async-tests.md
  33. 346
      docs/em/docs/advanced/behind-a-proxy.md
  34. 58
      docs/em/docs/advanced/conditional-openapi.md
  35. 109
      docs/em/docs/advanced/custom-request-and-route.md
  36. 300
      docs/em/docs/advanced/custom-response.md
  37. 98
      docs/em/docs/advanced/dataclasses.md
  38. 160
      docs/em/docs/advanced/events.md
  39. 314
      docs/em/docs/advanced/extending-openapi.md
  40. 267
      docs/em/docs/advanced/generate-clients.md
  41. 56
      docs/em/docs/advanced/graphql.md
  42. 24
      docs/em/docs/advanced/index.md
  43. 99
      docs/em/docs/advanced/middleware.md
  44. 156
      docs/em/docs/advanced/nosql-databases.md
  45. 179
      docs/em/docs/advanced/openapi-callbacks.md
  46. 170
      docs/em/docs/advanced/path-operation-advanced-configuration.md
  47. 33
      docs/em/docs/advanced/response-change-status-code.md
  48. 49
      docs/em/docs/advanced/response-cookies.md
  49. 63
      docs/em/docs/advanced/response-directly.md
  50. 42
      docs/em/docs/advanced/response-headers.md
  51. 113
      docs/em/docs/advanced/security/http-basic-auth.md
  52. 16
      docs/em/docs/advanced/security/index.md
  53. 269
      docs/em/docs/advanced/security/oauth2-scopes.md
  54. 382
      docs/em/docs/advanced/settings.md
  55. 529
      docs/em/docs/advanced/sql-databases-peewee.md
  56. 73
      docs/em/docs/advanced/sub-applications.md
  57. 77
      docs/em/docs/advanced/templates.md
  58. 95
      docs/em/docs/advanced/testing-database.md
  59. 49
      docs/em/docs/advanced/testing-dependencies.md
  60. 7
      docs/em/docs/advanced/testing-events.md
  61. 12
      docs/em/docs/advanced/testing-websockets.md
  62. 52
      docs/em/docs/advanced/using-request-directly.md
  63. 184
      docs/em/docs/advanced/websockets.md
  64. 37
      docs/em/docs/advanced/wsgi.md
  65. 414
      docs/em/docs/alternatives.md
  66. 430
      docs/em/docs/async.md
  67. 34
      docs/em/docs/benchmarks.md
  68. 465
      docs/em/docs/contributing.md
  69. 311
      docs/em/docs/deployment/concepts.md
  70. 258
      docs/em/docs/deployment/deta.md
  71. 698
      docs/em/docs/deployment/docker.md
  72. 190
      docs/em/docs/deployment/https.md
  73. 21
      docs/em/docs/deployment/index.md
  74. 145
      docs/em/docs/deployment/manually.md
  75. 178
      docs/em/docs/deployment/server-workers.md
  76. 87
      docs/em/docs/deployment/versions.md
  77. 91
      docs/em/docs/external-links.md
  78. 178
      docs/em/docs/fastapi-people.md
  79. 200
      docs/em/docs/features.md
  80. 265
      docs/em/docs/help-fastapi.md
  81. 79
      docs/em/docs/history-design-future.md
  82. 469
      docs/em/docs/index.md
  83. 84
      docs/em/docs/project-generation.md
  84. 490
      docs/em/docs/python-types.md
  85. 102
      docs/em/docs/tutorial/background-tasks.md
  86. 488
      docs/em/docs/tutorial/bigger-applications.md
  87. 68
      docs/em/docs/tutorial/body-fields.md
  88. 213
      docs/em/docs/tutorial/body-multiple-params.md
  89. 382
      docs/em/docs/tutorial/body-nested-models.md
  90. 155
      docs/em/docs/tutorial/body-updates.md
  91. 213
      docs/em/docs/tutorial/body.md
  92. 49
      docs/em/docs/tutorial/cookie-params.md
  93. 84
      docs/em/docs/tutorial/cors.md
  94. 112
      docs/em/docs/tutorial/debugging.md
  95. 247
      docs/em/docs/tutorial/dependencies/classes-as-dependencies.md
  96. 71
      docs/em/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md
  97. 219
      docs/em/docs/tutorial/dependencies/dependencies-with-yield.md
  98. 17
      docs/em/docs/tutorial/dependencies/global-dependencies.md
  99. 233
      docs/em/docs/tutorial/dependencies/index.md
  100. 110
      docs/em/docs/tutorial/dependencies/sub-dependencies.md

18
.github/ISSUE_TEMPLATE/question.yml → .github/DISCUSSION_TEMPLATE/questions.yml

@ -1,5 +1,3 @@
name: Question or Problem
description: Ask a question or ask about a problem
labels: [question]
body:
- type: markdown
@ -9,9 +7,9 @@ body:
Please follow these instructions, fill every question, and do every step. 🙏
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
I'm asking this because answering questions and solving problems in GitHub is what consumes most of the time.
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues.
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling questions.
All that, on top of all the incredible help provided by a bunch of community members, the [FastAPI Experts](https://fastapi.tiangolo.com/fastapi-people/#experts), that give a lot of their time to come here and help others.
@ -21,16 +19,16 @@ body:
And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. 😎
As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. 🤓
As there are too many questions, I'll have to discard and close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. 🤓
- type: checkboxes
id: checks
attributes:
label: First Check
description: Please confirm and check all the following options.
options:
- label: I added a very descriptive title to this issue.
- label: I added a very descriptive title here.
required: true
- label: I used the GitHub search to find a similar issue and didn't find it.
- label: I used the GitHub search to find a similar question and didn't find it.
required: true
- label: I searched the FastAPI documentation, with the integrated search.
required: true
@ -38,7 +36,7 @@ body:
required: true
- label: I already read and followed all the tutorial in the docs and didn't find an answer.
required: true
- label: I already checked if it is not related to FastAPI but to [Pydantic](https://github.com/samuelcolvin/pydantic).
- label: I already checked if it is not related to FastAPI but to [Pydantic](https://github.com/pydantic/pydantic).
required: true
- label: I already checked if it is not related to FastAPI but to [Swagger UI](https://github.com/swagger-api/swagger-ui).
required: true
@ -51,9 +49,9 @@ body:
description: |
After submitting this, I commit to one of:
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
* Read open questions until I find 2 where I can help someone and add a comment to help there.
* I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
* Implement a Pull Request for a confirmed bug.
* Review one Pull Request by downloading the code and following [all the review process](https://fastapi.tiangolo.com/help-fastapi/#review-pull-requests).
options:
- label: I commit to help with one of those options 👆

12
.github/ISSUE_TEMPLATE/config.yml

@ -2,3 +2,15 @@ blank_issues_enabled: false
contact_links:
- name: Security Contact
about: Please report security vulnerabilities to [email protected]
- name: Question or Problem
about: Ask a question or ask about a problem in GitHub Discussions.
url: https://github.com/tiangolo/fastapi/discussions/categories/questions
- name: Feature Request
about: To suggest an idea or ask about a feature, please start with a question saying what you would like to achieve. There might be a way to do it already.
url: https://github.com/tiangolo/fastapi/discussions/categories/questions
- name: Show and tell
about: Show what you built with FastAPI or to be used with FastAPI.
url: https://github.com/tiangolo/fastapi/discussions/categories/show-and-tell
- name: Translations
about: Coordinate translations in GitHub Discussions.
url: https://github.com/tiangolo/fastapi/discussions/categories/translations

181
.github/ISSUE_TEMPLATE/feature-request.yml

@ -1,181 +0,0 @@
name: Feature Request
description: Suggest an idea or ask for a feature that you would like to have in FastAPI
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
Thanks for your interest in FastAPI! 🚀
Please follow these instructions, fill every question, and do every step. 🙏
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues.
All that, on top of all the incredible help provided by a bunch of community members, the [FastAPI Experts](https://fastapi.tiangolo.com/fastapi-people/#experts), that give a lot of their time to come here and help others.
That's a lot of work they are doing, but if more FastAPI users came to help others like them just a little bit more, it would be much less effort for them (and you and me 😅).
By asking questions in a structured way (following this) it will be much easier to help you.
And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. 😎
As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. 🤓
- type: checkboxes
id: checks
attributes:
label: First Check
description: Please confirm and check all the following options.
options:
- label: I added a very descriptive title to this issue.
required: true
- label: I used the GitHub search to find a similar issue and didn't find it.
required: true
- label: I searched the FastAPI documentation, with the integrated search.
required: true
- label: I already searched in Google "How to X in FastAPI" and didn't find any information.
required: true
- label: I already read and followed all the tutorial in the docs and didn't find an answer.
required: true
- label: I already checked if it is not related to FastAPI but to [Pydantic](https://github.com/samuelcolvin/pydantic).
required: true
- label: I already checked if it is not related to FastAPI but to [Swagger UI](https://github.com/swagger-api/swagger-ui).
required: true
- label: I already checked if it is not related to FastAPI but to [ReDoc](https://github.com/Redocly/redoc).
required: true
- type: checkboxes
id: help
attributes:
label: Commit to Help
description: |
After submitting this, I commit to one of:
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
* I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
* Implement a Pull Request for a confirmed bug.
options:
- label: I commit to help with one of those options 👆
required: true
- type: textarea
id: example
attributes:
label: Example Code
description: |
Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case.
If I (or someone) can copy it, run it, and see it right away, there's a much higher chance I (or someone) will be able to help you.
placeholder: |
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
render: python
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: |
What is your feature request?
Write a short description telling me what you are trying to solve and what you are currently doing.
placeholder: |
* Open the browser and call the endpoint `/`.
* It returns a JSON with `{"Hello": "World"}`.
* I would like it to have an extra parameter to teleport me to the moon and back.
validations:
required: true
- type: textarea
id: wanted-solution
attributes:
label: Wanted Solution
description: |
Tell me what's the solution you would like.
placeholder: |
I would like it to have a `teleport_to_moon` parameter that defaults to `False`, and can be set to `True` to teleport me.
validations:
required: true
- type: textarea
id: wanted-code
attributes:
label: Wanted Code
description: Show me an example of how you would want the code to look like.
placeholder: |
from fastapi import FastAPI
app = FastAPI()
@app.get("/", teleport_to_moon=True)
def read_root():
return {"Hello": "World"}
render: python
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives
description: |
Tell me about alternatives you've considered.
placeholder: |
To wait for Space X moon travel plans to drop down long after they release them. But I would rather teleport.
- type: dropdown
id: os
attributes:
label: Operating System
description: What operating system are you on?
multiple: true
options:
- Linux
- Windows
- macOS
- Other
validations:
required: true
- type: textarea
id: os-details
attributes:
label: Operating System Details
description: You can add more details about your operating system here, in particular if you chose "Other".
- type: input
id: fastapi-version
attributes:
label: FastAPI Version
description: |
What FastAPI version are you using?
You can find the FastAPI version with:
```bash
python -c "import fastapi; print(fastapi.__version__)"
```
validations:
required: true
- type: input
id: python-version
attributes:
label: Python Version
description: |
What Python version are you using?
You can find the Python version with:
```bash
python --version
```
validations:
required: true
- type: textarea
id: context
attributes:
label: Additional Context
description: Add any additional context information or screenshots you think are useful.

22
.github/ISSUE_TEMPLATE/privileged.yml

@ -0,0 +1,22 @@
name: Privileged
description: You are @tiangolo or he asked you directly to create an issue here. If not, check the other options. 👇
body:
- type: markdown
attributes:
value: |
Thanks for your interest in FastAPI! 🚀
If you are not @tiangolo or he didn't ask you directly to create an issue here, please start the conversation in a [Question in GitHub Discussions](https://github.com/tiangolo/fastapi/discussions/categories/questions) instead.
- type: checkboxes
id: privileged
attributes:
label: Privileged issue
description: Confirm that you are allowed to create an issue here.
options:
- label: I'm @tiangolo or he asked me directly to create an issue here.
required: true
- type: textarea
id: content
attributes:
label: Issue Content
description: Add the content of the issue here.

419
.github/actions/notify-translations/app/main.py

@ -1,10 +1,11 @@
import logging
import random
import sys
import time
from pathlib import Path
from typing import Dict, Union
from typing import Any, Dict, List, Union, cast
import yaml
import httpx
from github import Github
from pydantic import BaseModel, BaseSettings, SecretStr
@ -13,12 +14,172 @@ lang_all_label = "lang-all"
approved_label = "approved-2"
translations_path = Path(__file__).parent / "translations.yml"
github_graphql_url = "https://api.github.com/graphql"
questions_translations_category_id = "DIC_kwDOCZduT84CT5P9"
all_discussions_query = """
query Q($category_id: ID) {
repository(name: "fastapi", owner: "tiangolo") {
discussions(categoryId: $category_id, first: 100) {
nodes {
title
id
number
labels(first: 10) {
edges {
node {
id
name
}
}
}
}
}
}
}
"""
translation_discussion_query = """
query Q($after: String, $discussion_number: Int!) {
repository(name: "fastapi", owner: "tiangolo") {
discussion(number: $discussion_number) {
comments(first: 100, after: $after) {
edges {
cursor
node {
id
url
body
}
}
}
}
}
}
"""
add_comment_mutation = """
mutation Q($discussion_id: ID!, $body: String!) {
addDiscussionComment(input: {discussionId: $discussion_id, body: $body}) {
comment {
id
url
body
}
}
}
"""
update_comment_mutation = """
mutation Q($comment_id: ID!, $body: String!) {
updateDiscussionComment(input: {commentId: $comment_id, body: $body}) {
comment {
id
url
body
}
}
}
"""
class Comment(BaseModel):
id: str
url: str
body: str
class UpdateDiscussionComment(BaseModel):
comment: Comment
class UpdateCommentData(BaseModel):
updateDiscussionComment: UpdateDiscussionComment
class UpdateCommentResponse(BaseModel):
data: UpdateCommentData
class AddDiscussionComment(BaseModel):
comment: Comment
class AddCommentData(BaseModel):
addDiscussionComment: AddDiscussionComment
class AddCommentResponse(BaseModel):
data: AddCommentData
class CommentsEdge(BaseModel):
node: Comment
cursor: str
class Comments(BaseModel):
edges: List[CommentsEdge]
class CommentsDiscussion(BaseModel):
comments: Comments
class CommentsRepository(BaseModel):
discussion: CommentsDiscussion
class CommentsData(BaseModel):
repository: CommentsRepository
class CommentsResponse(BaseModel):
data: CommentsData
class AllDiscussionsLabelNode(BaseModel):
id: str
name: str
class AllDiscussionsLabelsEdge(BaseModel):
node: AllDiscussionsLabelNode
class AllDiscussionsDiscussionLabels(BaseModel):
edges: List[AllDiscussionsLabelsEdge]
class AllDiscussionsDiscussionNode(BaseModel):
title: str
id: str
number: int
labels: AllDiscussionsDiscussionLabels
class AllDiscussionsDiscussions(BaseModel):
nodes: List[AllDiscussionsDiscussionNode]
class AllDiscussionsRepository(BaseModel):
discussions: AllDiscussionsDiscussions
class AllDiscussionsData(BaseModel):
repository: AllDiscussionsRepository
class AllDiscussionsResponse(BaseModel):
data: AllDiscussionsData
class Settings(BaseSettings):
github_repository: str
input_token: SecretStr
github_event_path: Path
github_event_name: Union[str, None] = None
httpx_timeout: int = 30
input_debug: Union[bool, None] = False
@ -30,6 +191,113 @@ class PartialGitHubEvent(BaseModel):
pull_request: PartialGitHubEventIssue
def get_graphql_response(
*,
settings: Settings,
query: str,
after: Union[str, None] = None,
category_id: Union[str, None] = None,
discussion_number: Union[int, None] = None,
discussion_id: Union[str, None] = None,
comment_id: Union[str, None] = None,
body: Union[str, None] = None,
) -> Dict[str, Any]:
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
# some fields are only used by one query, but GraphQL allows unused variables, so
# keep them here for simplicity
variables = {
"after": after,
"category_id": category_id,
"discussion_number": discussion_number,
"discussion_id": discussion_id,
"comment_id": comment_id,
"body": body,
}
response = httpx.post(
github_graphql_url,
headers=headers,
timeout=settings.httpx_timeout,
json={"query": query, "variables": variables, "operationName": "Q"},
)
if response.status_code != 200:
logging.error(
f"Response was not 200, after: {after}, category_id: {category_id}"
)
logging.error(response.text)
raise RuntimeError(response.text)
data = response.json()
if "errors" in data:
logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
logging.error(response.text)
raise RuntimeError(response.text)
return cast(Dict[str, Any], data)
def get_graphql_translation_discussions(*, settings: Settings):
data = get_graphql_response(
settings=settings,
query=all_discussions_query,
category_id=questions_translations_category_id,
)
graphql_response = AllDiscussionsResponse.parse_obj(data)
return graphql_response.data.repository.discussions.nodes
def get_graphql_translation_discussion_comments_edges(
*, settings: Settings, discussion_number: int, after: Union[str, None] = None
):
data = get_graphql_response(
settings=settings,
query=translation_discussion_query,
discussion_number=discussion_number,
after=after,
)
graphql_response = CommentsResponse.parse_obj(data)
return graphql_response.data.repository.discussion.comments.edges
def get_graphql_translation_discussion_comments(
*, settings: Settings, discussion_number: int
):
comment_nodes: List[Comment] = []
discussion_edges = get_graphql_translation_discussion_comments_edges(
settings=settings, discussion_number=discussion_number
)
while discussion_edges:
for discussion_edge in discussion_edges:
comment_nodes.append(discussion_edge.node)
last_edge = discussion_edges[-1]
discussion_edges = get_graphql_translation_discussion_comments_edges(
settings=settings,
discussion_number=discussion_number,
after=last_edge.cursor,
)
return comment_nodes
def create_comment(*, settings: Settings, discussion_id: str, body: str):
data = get_graphql_response(
settings=settings,
query=add_comment_mutation,
discussion_id=discussion_id,
body=body,
)
response = AddCommentResponse.parse_obj(data)
return response.data.addDiscussionComment.comment
def update_comment(*, settings: Settings, comment_id: str, body: str):
data = get_graphql_response(
settings=settings,
query=update_comment_mutation,
comment_id=comment_id,
body=body,
)
response = UpdateCommentResponse.parse_obj(data)
return response.data.updateDiscussionComment.comment
if __name__ == "__main__":
settings = Settings()
if settings.input_debug:
@ -45,60 +313,105 @@ if __name__ == "__main__":
)
contents = settings.github_event_path.read_text()
github_event = PartialGitHubEvent.parse_raw(contents)
translations_map: Dict[str, int] = yaml.safe_load(translations_path.read_text())
logging.debug(f"Using translations map: {translations_map}")
# Avoid race conditions with multiple labels
sleep_time = random.random() * 10 # random number between 0 and 10 seconds
pr = repo.get_pull(github_event.pull_request.number)
logging.debug(
f"Processing PR: {pr.number}, with anti-race condition sleep time: {sleep_time}"
logging.info(
f"Sleeping for {sleep_time} seconds to avoid "
"race conditions and multiple comments"
)
if pr.state == "open":
logging.debug(f"PR is open: {pr.number}")
label_strs = {label.name for label in pr.get_labels()}
if lang_all_label in label_strs and awaiting_label in label_strs:
time.sleep(sleep_time)
# Get PR
logging.debug(f"Processing PR: #{github_event.pull_request.number}")
pr = repo.get_pull(github_event.pull_request.number)
label_strs = {label.name for label in pr.get_labels()}
langs = []
for label in label_strs:
if label.startswith("lang-") and not label == lang_all_label:
langs.append(label[5:])
logging.info(f"PR #{pr.number} has labels: {label_strs}")
if not langs or lang_all_label not in label_strs:
logging.info(f"PR #{pr.number} doesn't seem to be a translation PR, skipping")
sys.exit(0)
# Generate translation map, lang ID to discussion
discussions = get_graphql_translation_discussions(settings=settings)
lang_to_discussion_map: Dict[str, AllDiscussionsDiscussionNode] = {}
for discussion in discussions:
for edge in discussion.labels.edges:
label = edge.node.name
if label.startswith("lang-") and not label == lang_all_label:
lang = label[5:]
lang_to_discussion_map[lang] = discussion
logging.debug(f"Using translations map: {lang_to_discussion_map}")
# Messages to create or check
new_translation_message = f"Good news everyone! 😉 There's a new translation PR to be reviewed: #{pr.number} by @{pr.user.login}. 🎉 This requires 2 approvals from native speakers to be merged. 🤓"
done_translation_message = f"~There's a new translation PR to be reviewed: #{pr.number} by @{pr.user.login}~ Good job! This is done. 🍰☕"
# Normally only one language, but still
for lang in langs:
if lang not in lang_to_discussion_map:
log_message = f"Could not find discussion for language: {lang}"
logging.error(log_message)
raise RuntimeError(log_message)
discussion = lang_to_discussion_map[lang]
logging.info(
f"Found a translation discussion for language: {lang} in discussion: #{discussion.number}"
)
already_notified_comment: Union[Comment, None] = None
already_done_comment: Union[Comment, None] = None
logging.info(
f"Checking current comments in discussion: #{discussion.number} to see if already notified about this PR: #{pr.number}"
)
comments = get_graphql_translation_discussion_comments(
settings=settings, discussion_number=discussion.number
)
for comment in comments:
if new_translation_message in comment.body:
already_notified_comment = comment
elif done_translation_message in comment.body:
already_done_comment = comment
logging.info(
f"Already notified comment: {already_notified_comment}, already done comment: {already_done_comment}"
)
if pr.state == "open" and awaiting_label in label_strs:
logging.info(
f"This PR seems to be a language translation and awaiting reviews: {pr.number}"
f"This PR seems to be a language translation and awaiting reviews: #{pr.number}"
)
if approved_label in label_strs:
message = (
f"It seems this PR already has the approved label: {pr.number}"
if already_notified_comment:
logging.info(
f"This PR #{pr.number} was already notified in comment: {already_notified_comment.url}"
)
logging.error(message)
raise RuntimeError(message)
langs = []
for label in label_strs:
if label.startswith("lang-") and not label == lang_all_label:
langs.append(label[5:])
for lang in langs:
if lang in translations_map:
num = translations_map[lang]
logging.info(
f"Found a translation issue for language: {lang} in issue: {num}"
)
issue = repo.get_issue(num)
message = f"Good news everyone! 😉 There's a new translation PR to be reviewed: #{pr.number} 🎉"
already_notified = False
time.sleep(sleep_time)
logging.info(
f"Sleeping for {sleep_time} seconds to avoid race conditions and multiple comments"
)
logging.info(
f"Checking current comments in issue: {num} to see if already notified about this PR: {pr.number}"
)
for comment in issue.get_comments():
if message in comment.body:
already_notified = True
if not already_notified:
logging.info(
f"Writing comment in issue: {num} about PR: {pr.number}"
)
issue.create_comment(message)
else:
logging.info(
f"Issue: {num} was already notified of PR: {pr.number}"
)
else:
logging.info(
f"Changing labels in a closed PR doesn't trigger comments, PR: {pr.number}"
)
else:
logging.info(
f"Writing notification comment about PR #{pr.number} in Discussion: #{discussion.number}"
)
comment = create_comment(
settings=settings,
discussion_id=discussion.id,
body=new_translation_message,
)
logging.info(f"Notified in comment: {comment.url}")
elif pr.state == "closed" or approved_label in label_strs:
logging.info(f"Already approved or closed PR #{pr.number}")
if already_done_comment:
logging.info(
f"This PR #{pr.number} was already marked as done in comment: {already_done_comment.url}"
)
elif already_notified_comment:
updated_comment = update_comment(
settings=settings,
comment_id=already_notified_comment.id,
body=done_translation_message,
)
logging.info(f"Marked as done in comment: {updated_comment.url}")
else:
logging.info(
f"There doesn't seem to be anything to be done about PR #{pr.number}"
)
logging.info("Finished")

21
.github/actions/notify-translations/app/translations.yml

@ -1,21 +0,0 @@
pt: 1211
es: 1218
zh: 1228
ru: 1362
it: 1556
ja: 1572
uk: 1748
tr: 1892
fr: 1972
ko: 2017
fa: 2041
pl: 3169
de: 3716
id: 3717
az: 3994
nl: 4701
uz: 4883
sv: 5146
he: 5157
ta: 5434
ar: 3349

214
.github/actions/people/app/main.py

@ -4,7 +4,7 @@ import sys
from collections import Counter, defaultdict
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Container, DefaultDict, Dict, List, Set, Union
from typing import Any, Container, DefaultDict, Dict, List, Set, Union
import httpx
import yaml
@ -12,6 +12,50 @@ from github import Github
from pydantic import BaseModel, BaseSettings, SecretStr
github_graphql_url = "https://api.github.com/graphql"
questions_category_id = "MDE4OkRpc2N1c3Npb25DYXRlZ29yeTMyMDAxNDM0"
discussions_query = """
query Q($after: String, $category_id: ID) {
repository(name: "fastapi", owner: "tiangolo") {
discussions(first: 100, after: $after, categoryId: $category_id) {
edges {
cursor
node {
number
author {
login
avatarUrl
url
}
title
createdAt
comments(first: 100) {
nodes {
createdAt
author {
login
avatarUrl
url
}
isAnswer
replies(first: 10) {
nodes {
createdAt
author {
login
avatarUrl
url
}
}
}
}
}
}
}
}
}
}
"""
issues_query = """
query Q($after: String) {
@ -131,15 +175,30 @@ class Author(BaseModel):
url: str
# Issues and Discussions
class CommentsNode(BaseModel):
createdAt: datetime
author: Union[Author, None] = None
class Replies(BaseModel):
nodes: List[CommentsNode]
class DiscussionsCommentsNode(CommentsNode):
replies: Replies
class Comments(BaseModel):
nodes: List[CommentsNode]
class DiscussionsComments(BaseModel):
nodes: List[DiscussionsCommentsNode]
class IssuesNode(BaseModel):
number: int
author: Union[Author, None] = None
@ -149,27 +208,59 @@ class IssuesNode(BaseModel):
comments: Comments
class DiscussionsNode(BaseModel):
number: int
author: Union[Author, None] = None
title: str
createdAt: datetime
comments: DiscussionsComments
class IssuesEdge(BaseModel):
cursor: str
node: IssuesNode
class DiscussionsEdge(BaseModel):
cursor: str
node: DiscussionsNode
class Issues(BaseModel):
edges: List[IssuesEdge]
class Discussions(BaseModel):
edges: List[DiscussionsEdge]
class IssuesRepository(BaseModel):
issues: Issues
class DiscussionsRepository(BaseModel):
discussions: Discussions
class IssuesResponseData(BaseModel):
repository: IssuesRepository
class DiscussionsResponseData(BaseModel):
repository: DiscussionsRepository
class IssuesResponse(BaseModel):
data: IssuesResponseData
class DiscussionsResponse(BaseModel):
data: DiscussionsResponseData
# PRs
class LabelNode(BaseModel):
name: str
@ -219,6 +310,9 @@ class PRsResponse(BaseModel):
data: PRsResponseData
# Sponsors
class SponsorEntity(BaseModel):
login: str
avatarUrl: str
@ -264,10 +358,16 @@ class Settings(BaseSettings):
def get_graphql_response(
*, settings: Settings, query: str, after: Union[str, None] = None
):
*,
settings: Settings,
query: str,
after: Union[str, None] = None,
category_id: Union[str, None] = None,
) -> Dict[str, Any]:
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
variables = {"after": after}
# category_id is only used by one query, but GraphQL allows unused variables, so
# keep it here for simplicity
variables = {"after": after, "category_id": category_id}
response = httpx.post(
github_graphql_url,
headers=headers,
@ -275,10 +375,16 @@ def get_graphql_response(
json={"query": query, "variables": variables, "operationName": "Q"},
)
if response.status_code != 200:
logging.error(f"Response was not 200, after: {after}")
logging.error(
f"Response was not 200, after: {after}, category_id: {category_id}"
)
logging.error(response.text)
raise RuntimeError(response.text)
data = response.json()
if "errors" in data:
logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
logging.error(response.text)
raise RuntimeError(response.text)
return data
@ -288,6 +394,21 @@ def get_graphql_issue_edges(*, settings: Settings, after: Union[str, None] = Non
return graphql_response.data.repository.issues.edges
def get_graphql_question_discussion_edges(
*,
settings: Settings,
after: Union[str, None] = None,
):
data = get_graphql_response(
settings=settings,
query=discussions_query,
after=after,
category_id=questions_category_id,
)
graphql_response = DiscussionsResponse.parse_obj(data)
return graphql_response.data.repository.discussions.edges
def get_graphql_pr_edges(*, settings: Settings, after: Union[str, None] = None):
data = get_graphql_response(settings=settings, query=prs_query, after=after)
graphql_response = PRsResponse.parse_obj(data)
@ -300,7 +421,7 @@ def get_graphql_sponsor_edges(*, settings: Settings, after: Union[str, None] = N
return graphql_response.data.user.sponsorshipsAsMaintainer.edges
def get_experts(settings: Settings):
def get_issues_experts(settings: Settings):
issue_nodes: List[IssuesNode] = []
issue_edges = get_graphql_issue_edges(settings=settings)
@ -326,13 +447,78 @@ def get_experts(settings: Settings):
for comment in issue.comments.nodes:
if comment.author:
authors[comment.author.login] = comment.author
if comment.author.login == issue_author_name:
continue
issue_commentors.add(comment.author.login)
if comment.author.login != issue_author_name:
issue_commentors.add(comment.author.login)
for author_name in issue_commentors:
commentors[author_name] += 1
if issue.createdAt > one_month_ago:
last_month_commentors[author_name] += 1
return commentors, last_month_commentors, authors
def get_discussions_experts(settings: Settings):
discussion_nodes: List[DiscussionsNode] = []
discussion_edges = get_graphql_question_discussion_edges(settings=settings)
while discussion_edges:
for discussion_edge in discussion_edges:
discussion_nodes.append(discussion_edge.node)
last_edge = discussion_edges[-1]
discussion_edges = get_graphql_question_discussion_edges(
settings=settings, after=last_edge.cursor
)
commentors = Counter()
last_month_commentors = Counter()
authors: Dict[str, Author] = {}
now = datetime.now(tz=timezone.utc)
one_month_ago = now - timedelta(days=30)
for discussion in discussion_nodes:
discussion_author_name = None
if discussion.author:
authors[discussion.author.login] = discussion.author
discussion_author_name = discussion.author.login
discussion_commentors = set()
for comment in discussion.comments.nodes:
if comment.author:
authors[comment.author.login] = comment.author
if comment.author.login != discussion_author_name:
discussion_commentors.add(comment.author.login)
for reply in comment.replies.nodes:
if reply.author:
authors[reply.author.login] = reply.author
if reply.author.login != discussion_author_name:
discussion_commentors.add(reply.author.login)
for author_name in discussion_commentors:
commentors[author_name] += 1
if discussion.createdAt > one_month_ago:
last_month_commentors[author_name] += 1
return commentors, last_month_commentors, authors
def get_experts(settings: Settings):
# Migrated to only use GitHub Discussions
# (
# issues_commentors,
# issues_last_month_commentors,
# issues_authors,
# ) = get_issues_experts(settings=settings)
(
discussions_commentors,
discussions_last_month_commentors,
discussions_authors,
) = get_discussions_experts(settings=settings)
# commentors = issues_commentors + discussions_commentors
commentors = discussions_commentors
# last_month_commentors = (
# issues_last_month_commentors + discussions_last_month_commentors
# )
last_month_commentors = discussions_last_month_commentors
# authors = {**issues_authors, **discussions_authors}
authors = {**discussions_authors}
return commentors, last_month_commentors, authors
@ -425,13 +611,13 @@ if __name__ == "__main__":
logging.info(f"Using config: {settings.json()}")
g = Github(settings.input_standard_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
issue_commentors, issue_last_month_commentors, issue_authors = get_experts(
question_commentors, question_last_month_commentors, question_authors = get_experts(
settings=settings
)
contributors, pr_commentors, reviewers, pr_authors = get_contributors(
settings=settings
)
authors = {**issue_authors, **pr_authors}
authors = {**question_authors, **pr_authors}
maintainers_logins = {"tiangolo"}
bot_names = {"codecov", "github-actions", "pre-commit-ci", "dependabot"}
maintainers = []
@ -440,7 +626,7 @@ if __name__ == "__main__":
maintainers.append(
{
"login": login,
"answers": issue_commentors[login],
"answers": question_commentors[login],
"prs": contributors[login],
"avatarUrl": user.avatarUrl,
"url": user.url,
@ -453,13 +639,13 @@ if __name__ == "__main__":
min_count_reviewer = 4
skip_users = maintainers_logins | bot_names
experts = get_top_users(
counter=issue_commentors,
counter=question_commentors,
min_count=min_count_expert,
authors=authors,
skip_users=skip_users,
)
last_month_active = get_top_users(
counter=issue_last_month_commentors,
counter=question_last_month_commentors,
min_count=min_count_last_month,
authors=authors,
skip_users=skip_users,

7
.github/actions/watch-previews/Dockerfile

@ -1,7 +0,0 @@
FROM python:3.7
RUN pip install httpx PyGithub "pydantic==1.5.1"
COPY ./app /app
CMD ["python", "/app/main.py"]

10
.github/actions/watch-previews/action.yml

@ -1,10 +0,0 @@
name: "Watch docs previews in PRs"
description: "Check PRs and trigger new docs deploys"
author: "Sebastián Ramírez <[email protected]>"
inputs:
token:
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}'
required: true
runs:
using: 'docker'
image: 'Dockerfile'

101
.github/actions/watch-previews/app/main.py

@ -1,101 +0,0 @@
import logging
from datetime import datetime
from pathlib import Path
from typing import List, Union
import httpx
from github import Github
from github.NamedUser import NamedUser
from pydantic import BaseModel, BaseSettings, SecretStr
github_api = "https://api.github.com"
netlify_api = "https://api.netlify.com"
class Settings(BaseSettings):
input_token: SecretStr
github_repository: str
github_event_path: Path
github_event_name: Union[str, None] = None
class Artifact(BaseModel):
id: int
node_id: str
name: str
size_in_bytes: int
url: str
archive_download_url: str
expired: bool
created_at: datetime
updated_at: datetime
class ArtifactResponse(BaseModel):
total_count: int
artifacts: List[Artifact]
def get_message(commit: str) -> str:
return f"Docs preview for commit {commit} at"
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
settings = Settings()
logging.info(f"Using config: {settings.json()}")
g = Github(settings.input_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
owner: NamedUser = repo.owner
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
prs = list(repo.get_pulls(state="open"))
response = httpx.get(
f"{github_api}/repos/{settings.github_repository}/actions/artifacts",
headers=headers,
)
data = response.json()
artifacts_response = ArtifactResponse.parse_obj(data)
for pr in prs:
logging.info("-----")
logging.info(f"Processing PR #{pr.number}: {pr.title}")
pr_comments = list(pr.get_issue_comments())
pr_commits = list(pr.get_commits())
last_commit = pr_commits[0]
for pr_commit in pr_commits:
if pr_commit.commit.author.date > last_commit.commit.author.date:
last_commit = pr_commit
commit = last_commit.commit.sha
logging.info(f"Last commit: {commit}")
message = get_message(commit)
notified = False
for pr_comment in pr_comments:
if message in pr_comment.body:
notified = True
logging.info(f"Docs preview was notified: {notified}")
if not notified:
artifact_name = f"docs-zip-{commit}"
use_artifact: Union[Artifact, None] = None
for artifact in artifacts_response.artifacts:
if artifact.name == artifact_name:
use_artifact = artifact
break
if not use_artifact:
logging.info("Artifact not available")
else:
logging.info(f"Existing artifact: {use_artifact.name}")
response = httpx.post(
"https://api.github.com/repos/tiangolo/fastapi/actions/workflows/preview-docs.yml/dispatches",
headers=headers,
json={
"ref": "master",
"inputs": {
"pr": f"{pr.number}",
"name": artifact_name,
"commit": commit,
},
},
)
logging.info(
f"Trigger sent, response status: {response.status_code} - content: {response.content}"
)
logging.info("Finished")

103
.github/workflows/build-docs.yml

@ -4,10 +4,68 @@ on:
branches:
- master
pull_request:
types: [opened, synchronize]
types:
- opened
- synchronize
jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v3
# For pull requests it's not necessary to checkout the code but for master it is
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
docs:
- README.md
- docs/**
- docs_src/**
- requirements-docs.txt
langs:
needs:
- changes
runs-on: ubuntu-latest
outputs:
langs: ${{ steps.show-langs.outputs.langs }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v05
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-docs.txt
# Install MkDocs Material Insiders here just to put it in the cache for the rest of the steps
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
- name: Export Language Codes
id: show-langs
run: |
echo "langs=$(python ./scripts/docs.py langs-json)" >> $GITHUB_OUTPUT
build-docs:
runs-on: ubuntu-18.04
needs:
- changes
- langs
if: ${{ needs.changes.outputs.docs == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
lang: ${{ fromJson(needs.langs.outputs.langs) }}
steps:
- name: Dump GitHub context
env:
@ -17,33 +75,40 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.11"
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v03
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v05
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[doc]
run: pip install -r requirements-docs.txt
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
- name: Update Languages
run: python ./scripts/docs.py update-languages
- uses: actions/cache@v3
with:
key: mkdocs-cards-${{ matrix.lang }}-${{ github.ref }}
path: docs/${{ matrix.lang }}/.cache
- name: Build Docs
run: python ./scripts/docs.py build-all
- name: Zip docs
run: bash ./scripts/zip-docs.sh
run: python ./scripts/docs.py build-lang ${{ matrix.lang }}
- uses: actions/upload-artifact@v3
with:
name: docs-zip
path: ./site/docs.zip
- name: Deploy to Netlify
uses: nwtgck/[email protected]
name: docs-site
path: ./site/**
# https://github.com/marketplace/actions/alls-green#why
docs-all-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- build-docs
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
publish-dir: './site'
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-commit-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
jobs: ${{ toJSON(needs) }}
allowed-skips: build-docs

29
.github/workflows/preview-docs.yml → .github/workflows/deploy-docs.yml

@ -1,4 +1,4 @@
name: Preview Docs
name: Deploy Docs
on:
workflow_run:
workflows:
@ -7,40 +7,43 @@ on:
- completed
jobs:
preview-docs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- name: Clean site
run: |
rm -rf ./site
mkdir ./site
- name: Download Artifact Docs
uses: dawidd6/[email protected]
id: download
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
if_no_artifact_found: ignore
github_token: ${{ secrets.FASTAPI_PREVIEW_DOCS_DOWNLOAD_ARTIFACTS }}
workflow: build-docs.yml
run_id: ${{ github.event.workflow_run.id }}
name: docs-zip
name: docs-site
path: ./site/
- name: Unzip docs
run: |
cd ./site
unzip docs.zip
rm -f docs.zip
- name: Deploy to Netlify
if: steps.download.outputs.found_artifact == 'true'
id: netlify
uses: nwtgck/[email protected]
with:
publish-dir: './site'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
production-deploy: ${{ github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' }}
github-token: ${{ secrets.FASTAPI_PREVIEW_DOCS_NETLIFY }}
enable-commit-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Comment Deploy
if: steps.netlify.outputs.deploy-url != ''
uses: ./.github/actions/comment-docs-preview-in-pr
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FASTAPI_PREVIEW_DOCS_COMMENT_DEPLOY }}
deploy_url: "${{ steps.netlify.outputs.deploy-url }}"

5
.github/workflows/issue-manager.yml

@ -2,7 +2,7 @@ name: Issue Manager
on:
schedule:
- cron: "0 0 * * *"
- cron: "10 3 * * *"
issue_comment:
types:
- created
@ -16,11 +16,12 @@ on:
jobs:
issue-manager:
if: github.repository_owner == 'tiangolo'
runs-on: ubuntu-latest
steps:
- uses: tiangolo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FASTAPI_ISSUE_MANAGER }}
config: >
{
"answered": {

3
.github/workflows/label-approved.yml

@ -6,8 +6,9 @@ on:
jobs:
label-approved:
if: github.repository_owner == 'tiangolo'
runs-on: ubuntu-latest
steps:
- uses: docker://tiangolo/label-approved:0.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FASTAPI_LABEL_APPROVED }}

4
.github/workflows/latest-changes.yml

@ -30,11 +30,9 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
with:
limit-access-to-actor: true
token: ${{ secrets.ACTIONS_TOKEN }}
standard_token: ${{ secrets.GITHUB_TOKEN }}
- uses: docker://tiangolo/latest-changes:0.0.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FASTAPI_LATEST_CHANGES }}
latest_changes_file: docs/en/docs/release-notes.md
latest_changes_header: '## Latest Changes\n\n'
debug_logs: true

3
.github/workflows/notify-translations.yml

@ -4,6 +4,7 @@ on:
pull_request_target:
types:
- labeled
- closed
jobs:
notify-translations:
@ -18,4 +19,4 @@ jobs:
limit-access-to-actor: true
- uses: ./.github/actions/notify-translations
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.FASTAPI_NOTIFY_TRANSLATIONS }}

8
.github/workflows/people.yml

@ -12,18 +12,20 @@ on:
jobs:
fastapi-people:
if: github.repository_owner == 'tiangolo'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Ref: https://github.com/actions/runner/issues/2033
- name: Fix git safe.directory in container
run: mkdir -p /home/runner/work/_temp/_github_home && printf "[safe]\n\tdirectory = /github/workspace" > /home/runner/work/_temp/_github_home/.gitconfig
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
with:
limit-access-to-actor: true
token: ${{ secrets.ACTIONS_TOKEN }}
standard_token: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/people
with:
token: ${{ secrets.ACTIONS_TOKEN }}
standard_token: ${{ secrets.GITHUB_TOKEN }}
standard_token: ${{ secrets.FASTAPI_PEOPLE }}

11
.github/workflows/publish.yml

@ -18,7 +18,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.7"
cache: "pip"
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
cache-dependency-path: pyproject.toml
- uses: actions/cache@v3
id: cache
@ -31,16 +32,10 @@ jobs:
- name: Build distribution
run: python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.5.2
uses: pypa/gh-action-pypi-publish@v1.8.6
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
# - name: Notify
# env:
# GITTER_TOKEN: ${{ secrets.GITTER_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TAG: ${{ github.event.release.name }}
# run: bash scripts/notify.sh

5
.github/workflows/smokeshow.yml

@ -20,8 +20,9 @@ jobs:
- run: pip install smokeshow
- uses: dawidd6/[email protected]4.2
- uses: dawidd6/[email protected]7.0
with:
github_token: ${{ secrets.FASTAPI_SMOKESHOW_DOWNLOAD_ARTIFACTS }}
workflow: test.yml
commit: ${{ github.event.workflow_run.head_sha }}
@ -30,6 +31,6 @@ jobs:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100
SMOKESHOW_GITHUB_CONTEXT: coverage
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.FASTAPI_SMOKESHOW_UPLOAD }}
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}

62
.github/workflows/test.yml

@ -5,34 +5,56 @@ on:
branches:
- master
pull_request:
types: [opened, synchronize]
types:
- opened
- synchronize
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
# cache-dependency-path: pyproject.toml
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v03
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
- name: Lint
run: bash scripts/lint.sh
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
# cache-dependency-path: pyproject.toml
- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v03
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -e .[all,dev,doc,test]
- name: Lint
run: bash scripts/lint.sh
run: pip install -r requirements-tests.txt
- run: mkdir coverage
- name: Test
run: bash scripts/test.sh
@ -44,34 +66,42 @@ jobs:
with:
name: coverage
path: coverage
coverage-combine:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: "pip"
cache-dependency-path: pyproject.toml
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
# cache-dependency-path: pyproject.toml
- name: Get coverage files
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- run: pip install coverage[toml]
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: htmlcov
# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- coverage-combine
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

2
.gitignore

@ -16,6 +16,7 @@ Pipfile.lock
env3.*
env
docs_build
site_build
venv
docs.zip
archive.zip
@ -23,3 +24,4 @@ archive.zip
# vim temporary files
*~
.*.sw?
.cache

21
.pre-commit-config.yaml

@ -1,8 +1,10 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-toml
@ -12,31 +14,20 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py3-plus
- --keep-runtime-typing
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.138
rev: v0.0.272
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.3.0
hooks:
- id: black
ci:

17
README.md

@ -46,17 +46,15 @@ The key features are:
<!-- sponsors -->
<a href="https://bit.ly/3dmXC5S" target="_blank" title="The data structure for unstructured multimodal data"><img src="https://fastapi.tiangolo.com/img/sponsors/docarray.svg"></a>
<a href="https://bit.ly/3JJ7y5C" target="_blank" title="Build cross-modal and multimodal applications on the cloud"><img src="https://fastapi.tiangolo.com/img/sponsors/jina2.svg"></a>
<a href="https://cryptapi.io/" target="_blank" title="CryptAPI: Your easy to use, secure and privacy oriented payment gateway."><img src="https://fastapi.tiangolo.com/img/sponsors/cryptapi.svg"></a>
<a href="https://doist.com/careers/9B437B1615-wa-senior-backend-engineer-python" target="_blank" title="Help us migrate doist to FastAPI"><img src="https://fastapi.tiangolo.com/img/sponsors/doist.svg"></a>
<a href="https://platform.sh/try-it-now/?utm_source=fastapi-signup&utm_medium=banner&utm_campaign=FastAPI-signup-June-2023" target="_blank" title="Build, run and scale your apps on a modern, reliable, and secure PaaS."><img src="https://fastapi.tiangolo.com/img/sponsors/platform-sh.png"></a>
<a href="https://www.deta.sh/?ref=fastapi" target="_blank" title="The launchpad for all your (team's) ideas"><img src="https://fastapi.tiangolo.com/img/sponsors/deta.svg"></a>
<a href="https://www.investsuite.com/jobs" target="_blank" title="Wealthtech jobs with FastAPI"><img src="https://fastapi.tiangolo.com/img/sponsors/investsuite.svg"></a>
<a href="https://training.talkpython.fm/fastapi-courses" target="_blank" title="FastAPI video courses on demand from people you trust"><img src="https://fastapi.tiangolo.com/img/sponsors/talkpython.png"></a>
<a href="https://testdriven.io/courses/tdd-fastapi/" target="_blank" title="Learn to build high-quality web apps with best practices"><img src="https://fastapi.tiangolo.com/img/sponsors/testdriven.svg"></a>
<a href="https://github.com/deepset-ai/haystack/" target="_blank" title="Build powerful search from composable, open source building blocks"><img src="https://fastapi.tiangolo.com/img/sponsors/haystack-fastapi.svg"></a>
<a href="https://www.udemy.com/course/fastapi-rest/" target="_blank" title="Learn FastAPI by building a complete project. Extend your knowledge on advanced web development-AWS, Payments, Emails."><img src="https://fastapi.tiangolo.com/img/sponsors/ines-course.jpg"></a>
<a href="https://careers.budget-insight.com/" target="_blank" title="Budget Insight is hiring!"><img src="https://fastapi.tiangolo.com/img/sponsors/budget-insight.svg"></a>
<a href="https://careers.powens.com/" target="_blank" title="Powens is hiring!"><img src="https://fastapi.tiangolo.com/img/sponsors/powens.png"></a>
<a href="https://www.svix.com/" target="_blank" title="Svix - Webhooks as a service"><img src="https://fastapi.tiangolo.com/img/sponsors/svix.svg"></a>
<a href="https://databento.com/" target="_blank" title="Pay as you go for market data"><img src="https://fastapi.tiangolo.com/img/sponsors/databento.svg"></a>
<!-- /sponsors -->
@ -102,6 +100,12 @@ The key features are:
---
"_If anyone is looking to build a production Python API, I would highly recommend **FastAPI**. It is **beautifully designed**, **simple to use** and **highly scalable**, it has become a **key component** in our API first development strategy and is driving many automations and services such as our Virtual TAC Engineer._"
<div style="text-align: right; margin-right: 10%;">Deon Pillsbury - <strong>Cisco</strong> <a href="https://www.linkedin.com/posts/deonpillsbury_cisco-cx-python-activity-6963242628536487936-trAp/" target="_blank"><small>(ref)</small></a></div>
---
## **Typer**, the FastAPI of CLIs
<a href="https://typer.tiangolo.com" target="_blank"><img src="https://typer.tiangolo.com/img/logo-margin/logo-margin-vector.svg" style="width: 20%;"></a>
@ -442,7 +446,6 @@ To understand more about it, see the section <a href="https://fastapi.tiangolo.c
Used by Pydantic:
* <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - for faster JSON <abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - for email validation.
Used by Starlette:

466
docs/az/docs/index.md

@ -1,466 +0,0 @@
{!../../../docs/missing-translation.md!}
<p align="center">
<a href="https://fastapi.tiangolo.com"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" alt="FastAPI"></a>
</p>
<p align="center">
<em>FastAPI framework, high performance, easy to learn, fast to code, ready for production</em>
</p>
<p align="center">
<a href="https://github.com/tiangolo/fastapi/actions?query=workflow%3ATest" target="_blank">
<img src="https://github.com/tiangolo/fastapi/workflows/Test/badge.svg" alt="Test">
</a>
<a href="https://codecov.io/gh/tiangolo/fastapi" target="_blank">
<img src="https://img.shields.io/codecov/c/github/tiangolo/fastapi?color=%2334D058" alt="Coverage">
</a>
<a href="https://pypi.org/project/fastapi" target="_blank">
<img src="https://img.shields.io/pypi/v/fastapi?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
</p>
---
**Documentation**: <a href="https://fastapi.tiangolo.com" target="_blank">https://fastapi.tiangolo.com</a>
**Source Code**: <a href="https://github.com/tiangolo/fastapi" target="_blank">https://github.com/tiangolo/fastapi</a>
---
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
The key features are:
* **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic). [One of the fastest Python frameworks available](#performance).
* **Fast to code**: Increase the speed to develop features by about 200% to 300%. *
* **Fewer bugs**: Reduce about 40% of human (developer) induced errors. *
* **Intuitive**: Great editor support. <abbr title="also known as auto-complete, autocompletion, IntelliSense">Completion</abbr> everywhere. Less time debugging.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank">OpenAPI</a> (previously known as Swagger) and <a href="https://json-schema.org/" class="external-link" target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
## Sponsors
<!-- sponsors -->
{% if sponsors %}
{% for sponsor in sponsors.gold -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor -%}
{%- for sponsor in sponsors.silver -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor %}
{% endif %}
<!-- /sponsors -->
<a href="https://fastapi.tiangolo.com/fastapi-people/#sponsors" class="external-link" target="_blank">Other sponsors</a>
## Opinions
"_[...] I'm using **FastAPI** a ton these days. [...] I'm actually planning to use it for all of my team's **ML services at Microsoft**. Some of them are getting integrated into the core **Windows** product and some **Office** products._"
<div style="text-align: right; margin-right: 10%;">Kabir Khan - <strong>Microsoft</strong> <a href="https://github.com/tiangolo/fastapi/pull/26" target="_blank"><small>(ref)</small></a></div>
---
"_We adopted the **FastAPI** library to spawn a **REST** server that can be queried to obtain **predictions**. [for Ludwig]_"
<div style="text-align: right; margin-right: 10%;">Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala - <strong>Uber</strong> <a href="https://eng.uber.com/ludwig-v0-2/" target="_blank"><small>(ref)</small></a></div>
---
"_**Netflix** is pleased to announce the open-source release of our **crisis management** orchestration framework: **Dispatch**! [built with **FastAPI**]_"
<div style="text-align: right; margin-right: 10%;">Kevin Glisson, Marc Vilanova, Forest Monsen - <strong>Netflix</strong> <a href="https://netflixtechblog.com/introducing-dispatch-da4b8a2a8072" target="_blank"><small>(ref)</small></a></div>
---
"_I’m over the moon excited about **FastAPI**. It’s so fun!_"
<div style="text-align: right; margin-right: 10%;">Brian Okken - <strong><a href="https://pythonbytes.fm/episodes/show/123/time-to-right-the-py-wrongs?time_in_sec=855" target="_blank">Python Bytes</a> podcast host</strong> <a href="https://twitter.com/brianokken/status/1112220079972728832" target="_blank"><small>(ref)</small></a></div>
---
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
<div style="text-align: right; margin-right: 10%;">Timothy Crosley - <strong><a href="https://www.hug.rest/" target="_blank">Hug</a> creator</strong> <a href="https://news.ycombinator.com/item?id=19455465" target="_blank"><small>(ref)</small></a></div>
---
"_If you're looking to learn one **modern framework** for building REST APIs, check out **FastAPI** [...] It's fast, easy to use and easy to learn [...]_"
"_We've switched over to **FastAPI** for our **APIs** [...] I think you'll like it [...]_"
<div style="text-align: right; margin-right: 10%;">Ines Montani - Matthew Honnibal - <strong><a href="https://explosion.ai" target="_blank">Explosion AI</a> founders - <a href="https://spacy.io" target="_blank">spaCy</a> creators</strong> <a href="https://twitter.com/_inesmontani/status/1144173225322143744" target="_blank"><small>(ref)</small></a> - <a href="https://twitter.com/honnibal/status/1144031421859655680" target="_blank"><small>(ref)</small></a></div>
---
## **Typer**, the FastAPI of CLIs
<a href="https://typer.tiangolo.com" target="_blank"><img src="https://typer.tiangolo.com/img/logo-margin/logo-margin-vector.svg" style="width: 20%;"></a>
If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be used in the terminal instead of a web API, check out <a href="https://typer.tiangolo.com/" class="external-link" target="_blank">**Typer**</a>.
**Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. ⌨️ 🚀
## Requirements
Python 3.7+
FastAPI stands on the shoulders of giants:
* <a href="https://www.starlette.io/" class="external-link" target="_blank">Starlette</a> for the web parts.
* <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> for the data parts.
## Installation
<div class="termy">
```console
$ pip install fastapi
---> 100%
```
</div>
You will also need an ASGI server, for production such as <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a> or <a href="https://gitlab.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>.
<div class="termy">
```console
$ pip install "uvicorn[standard]"
---> 100%
```
</div>
## Example
### Create it
* Create a file `main.py` with:
```Python
from typing import Optional
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
```
<details markdown="1">
<summary>Or use <code>async def</code>...</summary>
If your code uses `async` / `await`, use `async def`:
```Python hl_lines="9 14"
from typing import Optional
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
async def read_item(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
```
**Note**:
If you don't know, check the _"In a hurry?"_ section about <a href="https://fastapi.tiangolo.com/async/#in-a-hurry" target="_blank">`async` and `await` in the docs</a>.
</details>
### Run it
Run the server with:
<div class="termy">
```console
$ uvicorn main:app --reload
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [28720]
INFO: Started server process [28722]
INFO: Waiting for application startup.
INFO: Application startup complete.
```
</div>
<details markdown="1">
<summary>About the command <code>uvicorn main:app --reload</code>...</summary>
The command `uvicorn main:app` refers to:
* `main`: the file `main.py` (the Python "module").
* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
* `--reload`: make the server restart after code changes. Only do this for development.
</details>
### Check it
Open your browser at <a href="http://127.0.0.1:8000/items/5?q=somequery" class="external-link" target="_blank">http://127.0.0.1:8000/items/5?q=somequery</a>.
You will see the JSON response as:
```JSON
{"item_id": 5, "q": "somequery"}
```
You already created an API that:
* Receives HTTP requests in the _paths_ `/` and `/items/{item_id}`.
* Both _paths_ take `GET` <em>operations</em> (also known as HTTP _methods_).
* The _path_ `/items/{item_id}` has a _path parameter_ `item_id` that should be an `int`.
* The _path_ `/items/{item_id}` has an optional `str` _query parameter_ `q`.
### Interactive API docs
Now go to <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
You will see the automatic interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui" class="external-link" target="_blank">Swagger UI</a>):
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-01-swagger-ui-simple.png)
### Alternative API docs
And now, go to <a href="http://127.0.0.1:8000/redoc" class="external-link" target="_blank">http://127.0.0.1:8000/redoc</a>.
You will see the alternative automatic documentation (provided by <a href="https://github.com/Rebilly/ReDoc" class="external-link" target="_blank">ReDoc</a>):
![ReDoc](https://fastapi.tiangolo.com/img/index/index-02-redoc-simple.png)
## Example upgrade
Now modify the file `main.py` to receive a body from a `PUT` request.
Declare the body using standard Python types, thanks to Pydantic.
```Python hl_lines="4 9-12 25-27"
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
is_offer: Optional[bool] = None
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id}
```
The server should reload automatically (because you added `--reload` to the `uvicorn` command above).
### Interactive API docs upgrade
Now go to <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
* The interactive API documentation will be automatically updated, including the new body:
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-03-swagger-02.png)
* Click on the button "Try it out", it allows you to fill the parameters and directly interact with the API:
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-04-swagger-03.png)
* Then click on the "Execute" button, the user interface will communicate with your API, send the parameters, get the results and show them on the screen:
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-05-swagger-04.png)
### Alternative API docs upgrade
And now, go to <a href="http://127.0.0.1:8000/redoc" class="external-link" target="_blank">http://127.0.0.1:8000/redoc</a>.
* The alternative documentation will also reflect the new query parameter and body:
![ReDoc](https://fastapi.tiangolo.com/img/index/index-06-redoc-02.png)
### Recap
In summary, you declare **once** the types of parameters, body, etc. as function parameters.
You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard **Python 3.6+**.
For example, for an `int`:
```Python
item_id: int
```
or for a more complex `Item` model:
```Python
item: Item
```
...and with that single declaration you get:
* Editor support, including:
* Completion.
* Type checks.
* Validation of data:
* Automatic and clear errors when the data is invalid.
* Validation even for deeply nested JSON objects.
* <abbr title="also known as: serialization, parsing, marshalling">Conversion</abbr> of input data: coming from the network to Python data and types. Reading from:
* JSON.
* Path parameters.
* Query parameters.
* Cookies.
* Headers.
* Forms.
* Files.
* <abbr title="also known as: serialization, parsing, marshalling">Conversion</abbr> of output data: converting from Python data and types to network data (as JSON):
* Convert Python types (`str`, `int`, `float`, `bool`, `list`, etc).
* `datetime` objects.
* `UUID` objects.
* Database models.
* ...and many more.
* Automatic interactive API documentation, including 2 alternative user interfaces:
* Swagger UI.
* ReDoc.
---
Coming back to the previous code example, **FastAPI** will:
* Validate that there is an `item_id` in the path for `GET` and `PUT` requests.
* Validate that the `item_id` is of type `int` for `GET` and `PUT` requests.
* If it is not, the client will see a useful, clear error.
* Check if there is an optional query parameter named `q` (as in `http://127.0.0.1:8000/items/foo?q=somequery`) for `GET` requests.
* As the `q` parameter is declared with `= None`, it is optional.
* Without the `None` it would be required (as is the body in the case with `PUT`).
* For `PUT` requests to `/items/{item_id}`, Read the body as JSON:
* Check that it has a required attribute `name` that should be a `str`.
* Check that it has a required attribute `price` that has to be a `float`.
* Check that it has an optional attribute `is_offer`, that should be a `bool`, if present.
* All this would also work for deeply nested JSON objects.
* Convert from and to JSON automatically.
* Document everything with OpenAPI, that can be used by:
* Interactive documentation systems.
* Automatic client code generation systems, for many languages.
* Provide 2 interactive documentation web interfaces directly.
---
We just scratched the surface, but you already get the idea of how it all works.
Try changing the line with:
```Python
return {"item_name": item.name, "item_id": item_id}
```
...from:
```Python
... "item_name": item.name ...
```
...to:
```Python
... "item_price": item.price ...
```
...and see how your editor will auto-complete the attributes and know their types:
![editor support](https://fastapi.tiangolo.com/img/vscode-completion.png)
For a more complete example including more features, see the <a href="https://fastapi.tiangolo.com/tutorial/">Tutorial - User Guide</a>.
**Spoiler alert**: the tutorial - user guide includes:
* Declaration of **parameters** from other different places as: **headers**, **cookies**, **form fields** and **files**.
* How to set **validation constraints** as `maximum_length` or `regex`.
* A very powerful and easy to use **<abbr title="also known as components, resources, providers, services, injectables">Dependency Injection</abbr>** system.
* Security and authentication, including support for **OAuth2** with **JWT tokens** and **HTTP Basic** auth.
* More advanced (but equally easy) techniques for declaring **deeply nested JSON models** (thanks to Pydantic).
* Many extra features (thanks to Starlette) as:
* **WebSockets**
* **GraphQL**
* extremely easy tests based on `requests` and `pytest`
* **CORS**
* **Cookie Sessions**
* ...and more.
## Performance
Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as <a href="https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7" class="external-link" target="_blank">one of the fastest Python frameworks available</a>, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)
To understand more about it, see the section <a href="https://fastapi.tiangolo.com/benchmarks/" class="internal-link" target="_blank">Benchmarks</a>.
## Optional Dependencies
Used by Pydantic:
* <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - for faster JSON <abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - for email validation.
Used by Starlette:
* <a href="https://www.python-httpx.org" target="_blank"><code>httpx</code></a> - Required if you want to use the `TestClient`.
* <a href="https://jinja.palletsprojects.com" target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <a href="https://andrew-d.github.io/python-multipart/" target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <a href="https://pythonhosted.org/itsdangerous/" target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <a href="https://pyyaml.org/wiki/PyYAMLDocumentation" target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
* <a href="https://graphene-python.org/" target="_blank"><code>graphene</code></a> - Required for `GraphQLApp` support.
* <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - Required if you want to use `UJSONResponse`.
Used by FastAPI / Starlette:
* <a href="https://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <a href="https://github.com/ijl/orjson" target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
## License
This project is licensed under the terms of the MIT license.

145
docs/az/mkdocs.yml

@ -1,145 +0,0 @@
site_name: FastAPI
site_description: FastAPI framework, high performance, easy to learn, fast to code, ready for production
site_url: https://fastapi.tiangolo.com/az/
theme:
name: material
custom_dir: overrides
palette:
- media: '(prefers-color-scheme: light)'
scheme: default
primary: teal
accent: amber
toggle:
icon: material/lightbulb
name: Switch to light mode
- media: '(prefers-color-scheme: dark)'
scheme: slate
primary: teal
accent: amber
toggle:
icon: material/lightbulb-outline
name: Switch to dark mode
features:
- search.suggest
- search.highlight
- content.tabs.link
icon:
repo: fontawesome/brands/github-alt
logo: https://fastapi.tiangolo.com/img/icon-white.svg
favicon: https://fastapi.tiangolo.com/img/favicon.png
language: en
repo_name: tiangolo/fastapi
repo_url: https://github.com/tiangolo/fastapi
edit_uri: ''
plugins:
- search
- markdownextradata:
data: data
nav:
- FastAPI: index.md
- Languages:
- en: /
- az: /az/
- de: /de/
- es: /es/
- fa: /fa/
- fr: /fr/
- he: /he/
- id: /id/
- it: /it/
- ja: /ja/
- ko: /ko/
- nl: /nl/
- pl: /pl/
- pt: /pt/
- ru: /ru/
- sq: /sq/
- sv: /sv/
- tr: /tr/
- uk: /uk/
- zh: /zh/
markdown_extensions:
- toc:
permalink: true
- markdown.extensions.codehilite:
guess_lang: false
- mdx_include:
base_path: docs
- admonition
- codehilite
- extra
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format ''
- pymdownx.tabbed:
alternate_style: true
- attr_list
- md_in_html
extra:
analytics:
provider: google
property: UA-133183413-1
social:
- icon: fontawesome/brands/github-alt
link: https://github.com/tiangolo/fastapi
- icon: fontawesome/brands/discord
link: https://discord.gg/VQjSZaeJmf
- icon: fontawesome/brands/twitter
link: https://twitter.com/fastapi
- icon: fontawesome/brands/linkedin
link: https://www.linkedin.com/in/tiangolo
- icon: fontawesome/brands/dev
link: https://dev.to/tiangolo
- icon: fontawesome/brands/medium
link: https://medium.com/@tiangolo
- icon: fontawesome/solid/globe
link: https://tiangolo.com
alternate:
- link: /
name: en - English
- link: /az/
name: az
- link: /de/
name: de
- link: /es/
name: es - español
- link: /fa/
name: fa
- link: /fr/
name: fr - français
- link: /he/
name: he
- link: /id/
name: id
- link: /it/
name: it - italiano
- link: /ja/
name: ja - 日本語
- link: /ko/
name: ko - 한국어
- link: /nl/
name: nl
- link: /pl/
name: pl
- link: /pt/
name: pt - português
- link: /ru/
name: ru - русский язык
- link: /sq/
name: sq - shqip
- link: /sv/
name: sv - svenska
- link: /tr/
name: tr - Türkçe
- link: /uk/
name: uk - українська мова
- link: /zh/
name: zh - 汉语
extra_css:
- https://fastapi.tiangolo.com/css/termynal.css
- https://fastapi.tiangolo.com/css/custom.css
extra_javascript:
- https://fastapi.tiangolo.com/js/termynal.js
- https://fastapi.tiangolo.com/js/custom.js

1
docs/de/docs/index.md

@ -440,7 +440,6 @@ To understand more about it, see the section <a href="https://fastapi.tiangolo.c
Used by Pydantic:
* <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - for faster JSON <abbr title="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - for email validation.
Used by Starlette:

147
docs/de/mkdocs.yml

@ -1,146 +1 @@
site_name: FastAPI
site_description: FastAPI framework, high performance, easy to learn, fast to code, ready for production
site_url: https://fastapi.tiangolo.com/de/
theme:
name: material
custom_dir: overrides
palette:
- media: '(prefers-color-scheme: light)'
scheme: default
primary: teal
accent: amber
toggle:
icon: material/lightbulb
name: Switch to light mode
- media: '(prefers-color-scheme: dark)'
scheme: slate
primary: teal
accent: amber
toggle:
icon: material/lightbulb-outline
name: Switch to dark mode
features:
- search.suggest
- search.highlight
- content.tabs.link
icon:
repo: fontawesome/brands/github-alt
logo: https://fastapi.tiangolo.com/img/icon-white.svg
favicon: https://fastapi.tiangolo.com/img/favicon.png
language: de
repo_name: tiangolo/fastapi
repo_url: https://github.com/tiangolo/fastapi
edit_uri: ''
plugins:
- search
- markdownextradata:
data: data
nav:
- FastAPI: index.md
- Languages:
- en: /
- az: /az/
- de: /de/
- es: /es/
- fa: /fa/
- fr: /fr/
- he: /he/
- id: /id/
- it: /it/
- ja: /ja/
- ko: /ko/
- nl: /nl/
- pl: /pl/
- pt: /pt/
- ru: /ru/
- sq: /sq/
- sv: /sv/
- tr: /tr/
- uk: /uk/
- zh: /zh/
- features.md
markdown_extensions:
- toc:
permalink: true
- markdown.extensions.codehilite:
guess_lang: false
- mdx_include:
base_path: docs
- admonition
- codehilite
- extra
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format ''
- pymdownx.tabbed:
alternate_style: true
- attr_list
- md_in_html
extra:
analytics:
provider: google
property: UA-133183413-1
social:
- icon: fontawesome/brands/github-alt
link: https://github.com/tiangolo/fastapi
- icon: fontawesome/brands/discord
link: https://discord.gg/VQjSZaeJmf
- icon: fontawesome/brands/twitter
link: https://twitter.com/fastapi
- icon: fontawesome/brands/linkedin
link: https://www.linkedin.com/in/tiangolo
- icon: fontawesome/brands/dev
link: https://dev.to/tiangolo
- icon: fontawesome/brands/medium
link: https://medium.com/@tiangolo
- icon: fontawesome/solid/globe
link: https://tiangolo.com
alternate:
- link: /
name: en - English
- link: /az/
name: az
- link: /de/
name: de
- link: /es/
name: es - español
- link: /fa/
name: fa
- link: /fr/
name: fr - français
- link: /he/
name: he
- link: /id/
name: id
- link: /it/
name: it - italiano
- link: /ja/
name: ja - 日本語
- link: /ko/
name: ko - 한국어
- link: /nl/
name: nl
- link: /pl/
name: pl
- link: /pt/
name: pt - português
- link: /ru/
name: ru - русский язык
- link: /sq/
name: sq - shqip
- link: /sv/
name: sv - svenska
- link: /tr/
name: tr - Türkçe
- link: /uk/
name: uk - українська мова
- link: /zh/
name: zh - 汉语
extra_css:
- https://fastapi.tiangolo.com/css/termynal.css
- https://fastapi.tiangolo.com/css/custom.css
extra_javascript:
- https://fastapi.tiangolo.com/js/termynal.js
- https://fastapi.tiangolo.com/js/custom.js
INHERIT: ../en/mkdocs.yml

240
docs/em/docs/advanced/additional-responses.md

@ -0,0 +1,240 @@
# 🌖 📨 🗄
!!! warning
👉 👍 🏧 ❔.
🚥 👆 ▶️ ⏮️ **FastAPI**, 👆 💪 🚫 💪 👉.
👆 💪 📣 🌖 📨, ⏮️ 🌖 👔 📟, 🔉 🆎, 📛, ♒️.
👈 🌖 📨 🔜 🔌 🗄 🔗, 👫 🔜 😑 🛠️ 🩺.
✋️ 👈 🌖 📨 👆 ✔️ ⚒ 💭 👆 📨 `Response` 💖 `JSONResponse` 🔗, ⏮️ 👆 👔 📟 &amp; 🎚.
## 🌖 📨 ⏮️ `model`
👆 💪 🚶‍♀️ 👆 *➡ 🛠️ 👨‍🎨* 🔢 `responses`.
⚫️ 📨 `dict`, 🔑 👔 📟 🔠 📨, 💖 `200`, &amp; 💲 🎏 `dict`Ⓜ ⏮️ ℹ 🔠 👫.
🔠 👈 📨 `dict`Ⓜ 💪 ✔️ 🔑 `model`, ⚗ Pydantic 🏷, 💖 `response_model`.
**FastAPI** 🔜 ✊ 👈 🏷, 🏗 🚮 🎻 🔗 &amp; 🔌 ⚫️ ☑ 🥉 🗄.
🖼, 📣 ➕1️⃣ 📨 ⏮️ 👔 📟 `404` &amp; Pydantic 🏷 `Message`, 👆 💪 ✍:
```Python hl_lines="18 22"
{!../../../docs_src/additional_responses/tutorial001.py!}
```
!!! note
✔️ 🤯 👈 👆 ✔️ 📨 `JSONResponse` 🔗.
!!! info
`model` 🔑 🚫 🍕 🗄.
**FastAPI** 🔜 ✊ Pydantic 🏷 ⚪️➡️ 📤, 🏗 `JSON Schema`, &amp; 🚮 ⚫️ ☑ 🥉.
☑ 🥉:
* 🔑 `content`, 👈 ✔️ 💲 ➕1️⃣ 🎻 🎚 (`dict`) 👈 🔌:
* 🔑 ⏮️ 📻 🆎, ✅ `application/json`, 👈 🔌 💲 ➕1️⃣ 🎻 🎚, 👈 🔌:
* 🔑 `schema`, 👈 ✔️ 💲 🎻 🔗 ⚪️➡️ 🏷, 📥 ☑ 🥉.
* **FastAPI** 🚮 🔗 📥 🌐 🎻 🔗 ➕1️⃣ 🥉 👆 🗄 ↩️ ✅ ⚫️ 🔗. 👉 🌌, 🎏 🈸 &amp; 👩‍💻 💪 ⚙️ 👈 🎻 🔗 🔗, 🚚 👻 📟 ⚡ 🧰, ♒️.
🏗 📨 🗄 👉 *➡ 🛠️* 🔜:
```JSON hl_lines="3-12"
{
"responses": {
"404": {
"description": "Additional Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Message"
}
}
}
},
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Item"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
```
🔗 🔗 ➕1️⃣ 🥉 🔘 🗄 🔗:
```JSON hl_lines="4-16"
{
"components": {
"schemas": {
"Message": {
"title": "Message",
"required": [
"message"
],
"type": "object",
"properties": {
"message": {
"title": "Message",
"type": "string"
}
}
},
"Item": {
"title": "Item",
"required": [
"id",
"value"
],
"type": "object",
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"value": {
"title": "Value",
"type": "string"
}
}
},
"ValidationError": {
"title": "ValidationError",
"required": [
"loc",
"msg",
"type"
],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": {
"type": "string"
}
},
"msg": {
"title": "Message",
"type": "string"
},
"type": {
"title": "Error Type",
"type": "string"
}
}
},
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
"properties": {
"detail": {
"title": "Detail",
"type": "array",
"items": {
"$ref": "#/components/schemas/ValidationError"
}
}
}
}
}
}
}
```
## 🌖 🔉 🆎 👑 📨
👆 💪 ⚙️ 👉 🎏 `responses` 🔢 🚮 🎏 🔉 🆎 🎏 👑 📨.
🖼, 👆 💪 🚮 🌖 📻 🆎 `image/png`, 📣 👈 👆 *➡ 🛠️* 💪 📨 🎻 🎚 (⏮️ 📻 🆎 `application/json`) ⚖️ 🇩🇴 🖼:
```Python hl_lines="19-24 28"
{!../../../docs_src/additional_responses/tutorial002.py!}
```
!!! note
👀 👈 👆 ✔️ 📨 🖼 ⚙️ `FileResponse` 🔗.
!!! info
🚥 👆 ✔ 🎏 📻 🆎 🎯 👆 `responses` 🔢, FastAPI 🔜 🤔 📨 ✔️ 🎏 📻 🆎 👑 📨 🎓 (🔢 `application/json`).
✋️ 🚥 👆 ✔️ ✔ 🛃 📨 🎓 ⏮️ `None` 🚮 📻 🆎, FastAPI 🔜 ⚙️ `application/json` 🙆 🌖 📨 👈 ✔️ 👨‍💼 🏷.
## 🌀 ℹ
👆 💪 🌀 📨 ℹ ⚪️➡️ 💗 🥉, 🔌 `response_model`, `status_code`, &amp; `responses` 🔢.
👆 💪 📣 `response_model`, ⚙️ 🔢 👔 📟 `200` (⚖️ 🛃 1️⃣ 🚥 👆 💪), &amp; ⤴️ 📣 🌖 ℹ 👈 🎏 📨 `responses`, 🔗 🗄 🔗.
**FastAPI** 🔜 🚧 🌖 ℹ ⚪️➡️ `responses`, &amp; 🌀 ⚫️ ⏮️ 🎻 🔗 ⚪️➡️ 👆 🏷.
🖼, 👆 💪 📣 📨 ⏮️ 👔 📟 `404` 👈 ⚙️ Pydantic 🏷 &amp; ✔️ 🛃 `description`.
&amp; 📨 ⏮️ 👔 📟 `200` 👈 ⚙️ 👆 `response_model`, ✋️ 🔌 🛃 `example`:
```Python hl_lines="20-31"
{!../../../docs_src/additional_responses/tutorial003.py!}
```
⚫️ 🔜 🌐 🌀 &amp; 🔌 👆 🗄, &amp; 🎦 🛠️ 🩺:
<img src="/img/tutorial/additional-responses/image01.png">
## 🌀 🔢 📨 &amp; 🛃 🕐
👆 💪 💚 ✔️ 🔁 📨 👈 ✔ 📚 *➡ 🛠️*, ✋️ 👆 💚 🌀 👫 ⏮️ 🛃 📨 💚 🔠 *➡ 🛠️*.
📚 💼, 👆 💪 ⚙️ 🐍 ⚒ "🏗" `dict` ⏮️ `**dict_to_unpack`:
```Python
old_dict = {
"old key": "old value",
"second old key": "second old value",
}
new_dict = {**old_dict, "new key": "new value"}
```
📥, `new_dict` 🔜 🔌 🌐 🔑-💲 👫 ⚪️➡️ `old_dict` ➕ 🆕 🔑-💲 👫:
```Python
{
"old key": "old value",
"second old key": "second old value",
"new key": "new value",
}
```
👆 💪 ⚙️ 👈 ⚒ 🏤-⚙️ 🔢 📨 👆 *➡ 🛠️* &amp; 🌀 👫 ⏮️ 🌖 🛃 🕐.
🖼:
```Python hl_lines="13-17 26"
{!../../../docs_src/additional_responses/tutorial004.py!}
```
## 🌖 ℹ 🔃 🗄 📨
👀 ⚫️❔ ⚫️❔ 👆 💪 🔌 📨, 👆 💪 ✅ 👉 📄 🗄 🔧:
* <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responsesObject" class="external-link" target="_blank">🗄 📨 🎚</a>, ⚫️ 🔌 `Response Object`.
* <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responseObject" class="external-link" target="_blank">🗄 📨 🎚</a>, 👆 💪 🔌 🕳 ⚪️➡️ 👉 🔗 🔠 📨 🔘 👆 `responses` 🔢. ✅ `description`, `headers`, `content` (🔘 👉 👈 👆 📣 🎏 🔉 🆎 &amp; 🎻 🔗), &amp; `links`.

37
docs/em/docs/advanced/additional-status-codes.md

@ -0,0 +1,37 @@
# 🌖 👔 📟
🔢, **FastAPI** 🔜 📨 📨 ⚙️ `JSONResponse`, 🚮 🎚 👆 📨 ⚪️➡️ 👆 *➡ 🛠️* 🔘 👈 `JSONResponse`.
⚫️ 🔜 ⚙️ 🔢 👔 📟 ⚖️ 1️⃣ 👆 ⚒ 👆 *➡ 🛠️*.
## 🌖 👔 📟
🚥 👆 💚 📨 🌖 👔 📟 ↖️ ⚪️➡️ 👑 1️⃣, 👆 💪 👈 🛬 `Response` 🔗, 💖 `JSONResponse`, &amp; ⚒ 🌖 👔 📟 🔗.
🖼, ➡️ 💬 👈 👆 💚 ✔️ *➡ 🛠️* 👈 ✔ ℹ 🏬, &amp; 📨 🇺🇸🔍 👔 📟 2️⃣0️⃣0️⃣ "👌" 🕐❔ 🏆.
✋️ 👆 💚 ⚫️ 🚫 🆕 🏬. &amp; 🕐❔ 🏬 🚫 🔀 ⏭, ⚫️ ✍ 👫, &amp; 📨 🇺🇸🔍 👔 📟 2️⃣0️⃣1️⃣ "✍".
🏆 👈, 🗄 `JSONResponse`, &amp; 📨 👆 🎚 📤 🔗, ⚒ `status_code` 👈 👆 💚:
```Python hl_lines="4 25"
{!../../../docs_src/additional_status_codes/tutorial001.py!}
```
!!! warning
🕐❔ 👆 📨 `Response` 🔗, 💖 🖼 🔛, ⚫️ 🔜 📨 🔗.
⚫️ 🏆 🚫 🎻 ⏮️ 🏷, ♒️.
⚒ 💭 ⚫️ ✔️ 📊 👆 💚 ⚫️ ✔️, &amp; 👈 💲 ☑ 🎻 (🚥 👆 ⚙️ `JSONResponse`).
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.responses import JSONResponse`.
**FastAPI** 🚚 🎏 `starlette.responses` `fastapi.responses` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃. 🎏 ⏮️ `status`.
## 🗄 &amp; 🛠️ 🩺
🚥 👆 📨 🌖 👔 📟 &amp; 📨 🔗, 👫 🏆 🚫 🔌 🗄 🔗 (🛠️ 🩺), ↩️ FastAPI 🚫 ✔️ 🌌 💭 ⏪ ⚫️❔ 👆 🚶 📨.
✋️ 👆 💪 📄 👈 👆 📟, ⚙️: [🌖 📨](additional-responses.md){.internal-link target=_blank}.

70
docs/em/docs/advanced/advanced-dependencies.md

@ -0,0 +1,70 @@
# 🏧 🔗
## 🔗 🔗
🌐 🔗 👥 ✔️ 👀 🔧 🔢 ⚖️ 🎓.
✋️ 📤 💪 💼 🌐❔ 👆 💚 💪 ⚒ 🔢 🔛 🔗, 🍵 ✔️ 📣 📚 🎏 🔢 ⚖️ 🎓.
➡️ 🌈 👈 👥 💚 ✔️ 🔗 👈 ✅ 🚥 🔢 🔢 `q` 🔌 🔧 🎚.
✋️ 👥 💚 💪 🔗 👈 🔧 🎚.
## "🇧🇲" 👐
🐍 📤 🌌 ⚒ 👐 🎓 "🇧🇲".
🚫 🎓 ⚫️ (❔ ⏪ 🇧🇲), ✋️ 👐 👈 🎓.
👈, 👥 📣 👩‍🔬 `__call__`:
```Python hl_lines="10"
{!../../../docs_src/dependencies/tutorial011.py!}
```
👉 💼, 👉 `__call__` ⚫️❔ **FastAPI** 🔜 ⚙️ ✅ 🌖 🔢 &amp; 🎧-🔗, &amp; 👉 ⚫️❔ 🔜 🤙 🚶‍♀️ 💲 🔢 👆 *➡ 🛠️ 🔢* ⏪.
## 🔗 👐
&amp; 🔜, 👥 💪 ⚙️ `__init__` 📣 🔢 👐 👈 👥 💪 ⚙️ "🔗" 🔗:
```Python hl_lines="7"
{!../../../docs_src/dependencies/tutorial011.py!}
```
👉 💼, **FastAPI** 🏆 🚫 ⏱ 👆 ⚖️ 💅 🔃 `__init__`, 👥 🔜 ⚙️ ⚫️ 🔗 👆 📟.
## ✍ 👐
👥 💪 ✍ 👐 👉 🎓 ⏮️:
```Python hl_lines="16"
{!../../../docs_src/dependencies/tutorial011.py!}
```
&amp; 👈 🌌 👥 💪 "🔗" 👆 🔗, 👈 🔜 ✔️ `"bar"` 🔘 ⚫️, 🔢 `checker.fixed_content`.
## ⚙️ 👐 🔗
⤴️, 👥 💪 ⚙️ 👉 `checker` `Depends(checker)`, ↩️ `Depends(FixedContentQueryChecker)`, ↩️ 🔗 👐, `checker`, 🚫 🎓 ⚫️.
&amp; 🕐❔ ❎ 🔗, **FastAPI** 🔜 🤙 👉 `checker` 💖:
```Python
checker(q="somequery")
```
...&amp; 🚶‍♀️ ⚫️❔ 👈 📨 💲 🔗 👆 *➡ 🛠️ 🔢* 🔢 `fixed_content_included`:
```Python hl_lines="20"
{!../../../docs_src/dependencies/tutorial011.py!}
```
!!! tip
🌐 👉 💪 😑 🎭. &amp; ⚫️ 💪 🚫 📶 🆑 ❔ ⚫️ ⚠.
👫 🖼 😫 🙅, ✋️ 🎦 ❔ ⚫️ 🌐 👷.
📃 🔃 💂‍♂, 📤 🚙 🔢 👈 🛠️ 👉 🎏 🌌.
🚥 👆 🤔 🌐 👉, 👆 ⏪ 💭 ❔ 👈 🚙 🧰 💂‍♂ 👷 🔘.

162
docs/em/docs/advanced/async-sql-databases.md

@ -0,0 +1,162 @@
# 🔁 🗄 (🔗) 💽
👆 💪 ⚙️ <a href="https://github.com/encode/databases" class="external-link" target="_blank">`encode/databases`</a> ⏮️ **FastAPI** 🔗 💽 ⚙️ `async` &amp; `await`.
⚫️ 🔗 ⏮️:
* ✳
* ✳
* 🗄
👉 🖼, 👥 🔜 ⚙️ **🗄**, ↩️ ⚫️ ⚙️ 👁 📁 &amp; 🐍 ✔️ 🛠️ 🐕‍🦺. , 👆 💪 📁 👉 🖼 &amp; 🏃 ⚫️.
⏪, 👆 🏭 🈸, 👆 💪 💚 ⚙️ 💽 💽 💖 **✳**.
!!! tip
👆 💪 🛠️ 💭 ⚪️➡️ 📄 🔃 🇸🇲 🐜 ([🗄 (🔗) 💽](../tutorial/sql-databases.md){.internal-link target=_blank}), 💖 ⚙️ 🚙 🔢 🎭 🛠️ 💽, 🔬 👆 **FastAPI** 📟.
👉 📄 🚫 ✔ 📚 💭, 🌓 😑 <a href="https://www.starlette.io/database/" class="external-link" target="_blank">💃</a>.
## 🗄 &amp; ⚒ 🆙 `SQLAlchemy`
* 🗄 `SQLAlchemy`.
* ✍ `metadata` 🎚.
* ✍ 🏓 `notes` ⚙️ `metadata` 🎚.
```Python hl_lines="4 14 16-22"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
!!! tip
👀 👈 🌐 👉 📟 😁 🇸🇲 🐚.
`databases` 🚫 🔨 🕳 📥.
## 🗄 &amp; ⚒ 🆙 `databases`
* 🗄 `databases`.
* ✍ `DATABASE_URL`.
* ✍ `database` 🎚.
```Python hl_lines="3 9 12"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
!!! tip
🚥 👆 🔗 🎏 💽 (✅ ✳), 👆 🔜 💪 🔀 `DATABASE_URL`.
## ✍ 🏓
👉 💼, 👥 🏗 🏓 🎏 🐍 📁, ✋️ 🏭, 👆 🔜 🎲 💚 ✍ 👫 ⏮️ ⚗, 🛠️ ⏮️ 🛠️, ♒️.
📥, 👉 📄 🔜 🏃 🔗, ▶️️ ⏭ ▶️ 👆 **FastAPI** 🈸.
* ✍ `engine`.
* ✍ 🌐 🏓 ⚪️➡️ `metadata` 🎚.
```Python hl_lines="25-28"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
## ✍ 🏷
✍ Pydantic 🏷:
* 🗒 ✍ (`NoteIn`).
* 🗒 📨 (`Note`).
```Python hl_lines="31-33 36-39"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
🏗 👫 Pydantic 🏷, 🔢 💽 🔜 ✔, 🎻 (🗜), &amp; ✍ (📄).
, 👆 🔜 💪 👀 ⚫️ 🌐 🎓 🛠️ 🩺.
## 🔗 &amp; 🔌
* ✍ 👆 `FastAPI` 🈸.
* ✍ 🎉 🐕‍🦺 🔗 &amp; 🔌 ⚪️➡️ 💽.
```Python hl_lines="42 45-47 50-52"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
## ✍ 🗒
*➡ 🛠️ 🔢* ✍ 🗒:
```Python hl_lines="55-58"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
!!! Note
👀 👈 👥 🔗 ⏮️ 💽 ⚙️ `await`, *➡ 🛠️ 🔢* 📣 ⏮️ `async`.
### 👀 `response_model=List[Note]`
⚫️ ⚙️ `typing.List`.
👈 📄 (&amp; ✔, 🎻, ⛽) 🔢 💽, `list` `Note`Ⓜ.
## ✍ 🗒
*➡ 🛠️ 🔢* ✍ 🗒:
```Python hl_lines="61-65"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
!!! Note
👀 👈 👥 🔗 ⏮️ 💽 ⚙️ `await`, *➡ 🛠️ 🔢* 📣 ⏮️ `async`.
### 🔃 `{**note.dict(), "id": last_record_id}`
`note` Pydantic `Note` 🎚.
`note.dict()` 📨 `dict` ⏮️ 🚮 💽, 🕳 💖:
```Python
{
"text": "Some note",
"completed": False,
}
```
✋️ ⚫️ 🚫 ✔️ `id` 🏑.
👥 ✍ 🆕 `dict`, 👈 🔌 🔑-💲 👫 ⚪️➡️ `note.dict()` ⏮️:
```Python
{**note.dict()}
```
`**note.dict()` "unpacks" the key value pairs directly, so, `{**note.dict()}` would be, more or less, a copy of `note.dict()`.
&amp; ⤴️, 👥 ↔ 👈 📁 `dict`, ❎ ➕1️⃣ 🔑-💲 👫: `"id": last_record_id`:
```Python
{**note.dict(), "id": last_record_id}
```
, 🏁 🏁 📨 🔜 🕳 💖:
```Python
{
"id": 1,
"text": "Some note",
"completed": False,
}
```
## ✅ ⚫️
👆 💪 📁 👉 📟, &amp; 👀 🩺 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
📤 👆 💪 👀 🌐 👆 🛠️ 📄 &amp; 🔗 ⏮️ ⚫️:
<img src="/img/tutorial/async-sql-databases/image01.png">
## 🌅 ℹ
👆 💪 ✍ 🌅 🔃 <a href="https://github.com/encode/databases" class="external-link" target="_blank">`encode/databases` 🚮 📂 📃</a>.

92
docs/em/docs/advanced/async-tests.md

@ -0,0 +1,92 @@
# 🔁 💯
👆 ✔️ ⏪ 👀 ❔ 💯 👆 **FastAPI** 🈸 ⚙️ 🚚 `TestClient`. 🆙 🔜, 👆 ✔️ 🕴 👀 ❔ ✍ 🔁 💯, 🍵 ⚙️ `async` 🔢.
➖ 💪 ⚙️ 🔁 🔢 👆 💯 💪 ⚠, 🖼, 🕐❔ 👆 🔬 👆 💽 🔁. 🌈 👆 💚 💯 📨 📨 👆 FastAPI 🈸 &amp; ⤴️ ✔ 👈 👆 👩‍💻 ⏪ ✍ ☑ 💽 💽, ⏪ ⚙️ 🔁 💽 🗃.
➡️ 👀 ❔ 👥 💪 ⚒ 👈 👷.
## pytest.mark.anyio
🚥 👥 💚 🤙 🔁 🔢 👆 💯, 👆 💯 🔢 ✔️ 🔁. AnyIO 🚚 👌 📁 👉, 👈 ✔ 👥 ✔ 👈 💯 🔢 🤙 🔁.
## 🇸🇲
🚥 👆 **FastAPI** 🈸 ⚙️ 😐 `def` 🔢 ↩️ `async def`, ⚫️ `async` 🈸 🔘.
`TestClient` 🔨 🎱 🔘 🤙 🔁 FastAPI 🈸 👆 😐 `def` 💯 🔢, ⚙️ 🐩 ✳. ✋️ 👈 🎱 🚫 👷 🚫🔜 🕐❔ 👥 ⚙️ ⚫️ 🔘 🔁 🔢. 🏃 👆 💯 🔁, 👥 💪 🙅‍♂ 📏 ⚙️ `TestClient` 🔘 👆 💯 🔢.
`TestClient` ⚓️ 🔛 <a href="https://www.python-httpx.org" class="external-link" target="_blank">🇸🇲</a>, &amp; ↩️, 👥 💪 ⚙️ ⚫️ 🔗 💯 🛠️.
## 🖼
🙅 🖼, ➡️ 🤔 📁 📊 🎏 1️⃣ 🔬 [🦏 🈸](../tutorial/bigger-applications.md){.internal-link target=_blank} &amp; [🔬](../tutorial/testing.md){.internal-link target=_blank}:
```
.
├── app
│   ├── __init__.py
│   ├── main.py
│   └── test_main.py
```
📁 `main.py` 🔜 ✔️:
```Python
{!../../../docs_src/async_tests/main.py!}
```
📁 `test_main.py` 🔜 ✔️ 💯 `main.py`, ⚫️ 💪 👀 💖 👉 🔜:
```Python
{!../../../docs_src/async_tests/test_main.py!}
```
## 🏃 ⚫️
👆 💪 🏃 👆 💯 🐌 📨:
<div class="termy">
```console
$ pytest
---> 100%
```
</div>
## ℹ
📑 `@pytest.mark.anyio` 💬 ✳ 👈 👉 💯 🔢 🔜 🤙 🔁:
```Python hl_lines="7"
{!../../../docs_src/async_tests/test_main.py!}
```
!!! tip
🗒 👈 💯 🔢 🔜 `async def` ↩️ `def` ⏭ 🕐❔ ⚙️ `TestClient`.
⤴️ 👥 💪 ✍ `AsyncClient` ⏮️ 📱, &amp; 📨 🔁 📨 ⚫️, ⚙️ `await`.
```Python hl_lines="9-10"
{!../../../docs_src/async_tests/test_main.py!}
```
👉 🌓:
```Python
response = client.get('/')
```
...👈 👥 ⚙️ ⚒ 👆 📨 ⏮️ `TestClient`.
!!! tip
🗒 👈 👥 ⚙️ 🔁/⌛ ⏮️ 🆕 `AsyncClient` - 📨 🔁.
## 🎏 🔁 🔢 🤙
🔬 🔢 🔜 🔁, 👆 💪 🔜 🤙 (&amp; `await`) 🎏 `async` 🔢 ↖️ ⚪️➡️ 📨 📨 👆 FastAPI 🈸 👆 💯, ⚫️❔ 👆 🔜 🤙 👫 🙆 🙆 👆 📟.
!!! tip
🚥 👆 ⚔ `RuntimeError: Task attached to a different loop` 🕐❔ 🛠️ 🔁 🔢 🤙 👆 💯 (✅ 🕐❔ ⚙️ <a href="https://stackoverflow.com/questions/41584243/runtimeerror-task-attached-to-a-different-loop" class="external-link" target="_blank">✳ MotorClient</a>) 💭 🔗 🎚 👈 💪 🎉 ➰ 🕴 🏞 🔁 🔢, ✅ `'@app.on_event("startup")` ⏲.

346
docs/em/docs/advanced/behind-a-proxy.md

@ -0,0 +1,346 @@
# ⛅ 🗳
⚠, 👆 5️⃣📆 💪 ⚙️ **🗳** 💽 💖 Traefik ⚖️ 👌 ⏮️ 📳 👈 🚮 ➕ ➡ 🔡 👈 🚫 👀 👆 🈸.
👫 💼 👆 💪 ⚙️ `root_path` 🔗 👆 🈸.
`root_path` 🛠️ 🚚 🔫 🔧 (👈 FastAPI 🏗 🔛, 🔘 💃).
`root_path` ⚙️ 🍵 👫 🎯 💼.
&amp; ⚫️ ⚙️ 🔘 🕐❔ 🗜 🎧-🈸.
## 🗳 ⏮️ 🎞 ➡ 🔡
✔️ 🗳 ⏮️ 🎞 ➡ 🔡, 👉 💼, ⛓ 👈 👆 💪 📣 ➡ `/app` 👆 📟, ✋️ ⤴️, 👆 🚮 🧽 🔛 🔝 (🗳) 👈 🔜 🚮 👆 **FastAPI** 🈸 🔽 ➡ 💖 `/api/v1`.
👉 💼, ⏮️ ➡ `/app` 🔜 🤙 🍦 `/api/v1/app`.
✋️ 🌐 👆 📟 ✍ 🤔 📤 `/app`.
&amp; 🗳 🔜 **"❎"** **➡ 🔡** 🔛 ✈ ⏭ 📶 📨 Uvicorn, 🚧 👆 🈸 🤔 👈 ⚫️ 🍦 `/app`, 👈 👆 🚫 ✔️ ℹ 🌐 👆 📟 🔌 🔡 `/api/v1`.
🆙 📥, 🌐 🔜 👷 🛎.
✋️ ⤴️, 🕐❔ 👆 📂 🛠️ 🩺 🎚 (🕸), ⚫️ 🔜 ⌛ 🤚 🗄 🔗 `/openapi.json`, ↩️ `/api/v1/openapi.json`.
, 🕸 (👈 🏃 🖥) 🔜 🔄 🏆 `/openapi.json` &amp; 🚫🔜 💪 🤚 🗄 🔗.
↩️ 👥 ✔️ 🗳 ⏮️ ➡ 🔡 `/api/v1` 👆 📱, 🕸 💪 ☕ 🗄 🔗 `/api/v1/openapi.json`.
```mermaid
graph LR
browser("Browser")
proxy["Proxy on http://0.0.0.0:9999/api/v1/app"]
server["Server on http://127.0.0.1:8000/app"]
browser --> proxy
proxy --> server
```
!!! tip
📢 `0.0.0.0` 🛎 ⚙️ ⛓ 👈 📋 👂 🔛 🌐 📢 💪 👈 🎰/💽.
🩺 🎚 🔜 💪 🗄 🔗 📣 👈 👉 🛠️ `server` 🔎 `/api/v1` (⛅ 🗳). 🖼:
```JSON hl_lines="4-8"
{
"openapi": "3.0.2",
// More stuff here
"servers": [
{
"url": "/api/v1"
}
],
"paths": {
// More stuff here
}
}
```
👉 🖼, "🗳" 💪 🕳 💖 **Traefik**. &amp; 💽 🔜 🕳 💖 **Uvicorn**, 🏃‍♂ 👆 FastAPI 🈸.
### 🚚 `root_path`
🏆 👉, 👆 💪 ⚙️ 📋 ⏸ 🎛 `--root-path` 💖:
<div class="termy">
```console
$ uvicorn main:app --root-path /api/v1
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
🚥 👆 ⚙️ Hypercorn, ⚫️ ✔️ 🎛 `--root-path`.
!!! note "📡 ℹ"
🔫 🔧 🔬 `root_path` 👉 ⚙️ 💼.
&amp; `--root-path` 📋 ⏸ 🎛 🚚 👈 `root_path`.
### ✅ ⏮️ `root_path`
👆 💪 🤚 ⏮️ `root_path` ⚙️ 👆 🈸 🔠 📨, ⚫️ 🍕 `scope` 📖 (👈 🍕 🔫 🔌).
📥 👥 ✅ ⚫️ 📧 🎦 🎯.
```Python hl_lines="8"
{!../../../docs_src/behind_a_proxy/tutorial001.py!}
```
⤴️, 🚥 👆 ▶️ Uvicorn ⏮️:
<div class="termy">
```console
$ uvicorn main:app --root-path /api/v1
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
📨 🔜 🕳 💖:
```JSON
{
"message": "Hello World",
"root_path": "/api/v1"
}
```
### ⚒ `root_path` FastAPI 📱
👐, 🚥 👆 🚫 ✔️ 🌌 🚚 📋 ⏸ 🎛 💖 `--root-path` ⚖️ 🌓, 👆 💪 ⚒ `root_path` 🔢 🕐❔ 🏗 👆 FastAPI 📱:
```Python hl_lines="3"
{!../../../docs_src/behind_a_proxy/tutorial002.py!}
```
🚶‍♀️ `root_path` `FastAPI` 🔜 🌓 🚶‍♀️ `--root-path` 📋 ⏸ 🎛 Uvicorn ⚖️ Hypercorn.
### 🔃 `root_path`
✔️ 🤯 👈 💽 (Uvicorn) 🏆 🚫 ⚙️ 👈 `root_path` 🕳 🙆 🌘 🚶‍♀️ ⚫️ 📱.
✋️ 🚥 👆 🚶 ⏮️ 👆 🖥 <a href="http://127.0.0.1:8000" class="external-link" target="_blank">http://127.0.0.1:8000/app</a> 👆 🔜 👀 😐 📨:
```JSON
{
"message": "Hello World",
"root_path": "/api/v1"
}
```
, ⚫️ 🏆 🚫 ⌛ 🔐 `http://127.0.0.1:8000/api/v1/app`.
Uvicorn 🔜 ⌛ 🗳 🔐 Uvicorn `http://127.0.0.1:8000/app`, &amp; ⤴️ ⚫️ 🔜 🗳 🎯 🚮 ➕ `/api/v1` 🔡 🔛 🔝.
## 🔃 🗳 ⏮️ 🎞 ➡ 🔡
✔️ 🤯 👈 🗳 ⏮️ 🎞 ➡ 🔡 🕴 1️⃣ 🌌 🔗 ⚫️.
🎲 📚 💼 🔢 🔜 👈 🗳 🚫 ✔️ 🏚 ➡ 🔡.
💼 💖 👈 (🍵 🎞 ➡ 🔡), 🗳 🔜 👂 🔛 🕳 💖 `https://myawesomeapp.com`, &amp; ⤴️ 🚥 🖥 🚶 `https://myawesomeapp.com/api/v1/app` &amp; 👆 💽 (✅ Uvicorn) 👂 🔛 `http://127.0.0.1:8000` 🗳 (🍵 🎞 ➡ 🔡) 🔜 🔐 Uvicorn 🎏 ➡: `http://127.0.0.1:8000/api/v1/app`.
## 🔬 🌐 ⏮️ Traefik
👆 💪 💪 🏃 🥼 🌐 ⏮️ 🎞 ➡ 🔡 ⚙️ <a href="https://docs.traefik.io/" class="external-link" target="_blank">Traefik</a>.
<a href="https://github.com/containous/traefik/releases" class="external-link" target="_blank">⏬ Traefik</a>, ⚫️ 👁 💱, 👆 💪 ⚗ 🗜 📁 &amp; 🏃 ⚫️ 🔗 ⚪️➡️ 📶.
⤴️ ✍ 📁 `traefik.toml` ⏮️:
```TOML hl_lines="3"
[entryPoints]
[entryPoints.http]
address = ":9999"
[providers]
[providers.file]
filename = "routes.toml"
```
👉 💬 Traefik 👂 🔛 ⛴ 9️⃣9️⃣9️⃣9️⃣ &amp; ⚙️ ➕1️⃣ 📁 `routes.toml`.
!!! tip
👥 ⚙️ ⛴ 9️⃣9️⃣9️⃣9️⃣ ↩️ 🐩 🇺🇸🔍 ⛴ 8️⃣0️⃣ 👈 👆 🚫 ✔️ 🏃 ⚫️ ⏮️ 📡 (`sudo`) 😌.
🔜 ✍ 👈 🎏 📁 `routes.toml`:
```TOML hl_lines="5 12 20"
[http]
[http.middlewares]
[http.middlewares.api-stripprefix.stripPrefix]
prefixes = ["/api/v1"]
[http.routers]
[http.routers.app-http]
entryPoints = ["http"]
service = "app"
rule = "PathPrefix(`/api/v1`)"
middlewares = ["api-stripprefix"]
[http.services]
[http.services.app]
[http.services.app.loadBalancer]
[[http.services.app.loadBalancer.servers]]
url = "http://127.0.0.1:8000"
```
👉 📁 🔗 Traefik ⚙️ ➡ 🔡 `/api/v1`.
&amp; ⤴️ ⚫️ 🔜 ❎ 🚮 📨 👆 Uvicorn 🏃‍♂ 🔛 `http://127.0.0.1:8000`.
🔜 ▶️ Traefik:
<div class="termy">
```console
$ ./traefik --configFile=traefik.toml
INFO[0000] Configuration loaded from file: /home/user/awesomeapi/traefik.toml
```
</div>
&amp; 🔜 ▶️ 👆 📱 ⏮️ Uvicorn, ⚙️ `--root-path` 🎛:
<div class="termy">
```console
$ uvicorn main:app --root-path /api/v1
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
### ✅ 📨
🔜, 🚥 👆 🚶 📛 ⏮️ ⛴ Uvicorn: <a href="http://127.0.0.1:8000/app" class="external-link" target="_blank">http://127.0.0.1:8000/app</a>, 👆 🔜 👀 😐 📨:
```JSON
{
"message": "Hello World",
"root_path": "/api/v1"
}
```
!!! tip
👀 👈 ✋️ 👆 🔐 ⚫️ `http://127.0.0.1:8000/app` ⚫️ 🎦 `root_path` `/api/v1`, ✊ ⚪️➡️ 🎛 `--root-path`.
&amp; 🔜 📂 📛 ⏮️ ⛴ Traefik, ✅ ➡ 🔡: <a href="http://127.0.0.1:9999/api/v1/app" class="external-link" target="_blank">http://127.0.0.1:9999/api/v1/app</a>.
👥 🤚 🎏 📨:
```JSON
{
"message": "Hello World",
"root_path": "/api/v1"
}
```
✋️ 👉 🕰 📛 ⏮️ 🔡 ➡ 🚚 🗳: `/api/v1`.
↗️, 💭 📥 👈 👱 🔜 🔐 📱 🔘 🗳, ⏬ ⏮️ ➡ 🔡 `/app/v1` "☑" 1️⃣.
&amp; ⏬ 🍵 ➡ 🔡 (`http://127.0.0.1:8000/app`), 🚚 Uvicorn 🔗, 🔜 🎯 _🗳_ (Traefik) 🔐 ⚫️.
👈 🎦 ❔ 🗳 (Traefik) ⚙️ ➡ 🔡 &amp; ❔ 💽 (Uvicorn) ⚙️ `root_path` ⚪️➡️ 🎛 `--root-path`.
### ✅ 🩺 🎚
✋️ 📥 🎊 🍕. 👶
"🛂" 🌌 🔐 📱 🔜 🔘 🗳 ⏮️ ➡ 🔡 👈 👥 🔬. , 👥 🔜 ⌛, 🚥 👆 🔄 🩺 🎚 🍦 Uvicorn 🔗, 🍵 ➡ 🔡 📛, ⚫️ 🏆 🚫 👷, ↩️ ⚫️ ⌛ 🔐 🔘 🗳.
👆 💪 ✅ ⚫️ <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>:
<img src="/img/tutorial/behind-a-proxy/image01.png">
✋️ 🚥 👥 🔐 🩺 🎚 "🛂" 📛 ⚙️ 🗳 ⏮️ ⛴ `9999`, `/api/v1/docs`, ⚫️ 👷 ☑ ❗ 👶
👆 💪 ✅ ⚫️ <a href="http://127.0.0.1:9999/api/v1/docs" class="external-link" target="_blank">http://127.0.0.1:9999/api/v1/docs</a>:
<img src="/img/tutorial/behind-a-proxy/image02.png">
▶️️ 👥 💚 ⚫️. 👶 👶
👉 ↩️ FastAPI ⚙️ 👉 `root_path` ✍ 🔢 `server` 🗄 ⏮️ 📛 🚚 `root_path`.
## 🌖 💽
!!! warning
👉 🌅 🏧 ⚙️ 💼. 💭 🆓 🚶 ⚫️.
🔢, **FastAPI** 🔜 ✍ `server` 🗄 🔗 ⏮️ 📛 `root_path`.
✋️ 👆 💪 🚚 🎏 🎛 `servers`, 🖼 🚥 👆 💚 *🎏* 🩺 🎚 🔗 ⏮️ 🏗 &amp; 🏭 🌐.
🚥 👆 🚶‍♀️ 🛃 📇 `servers` &amp; 📤 `root_path` (↩️ 👆 🛠️ 👨‍❤‍👨 ⛅ 🗳), **FastAPI** 🔜 📩 "💽" ⏮️ 👉 `root_path` ▶️ 📇.
🖼:
```Python hl_lines="4-7"
{!../../../docs_src/behind_a_proxy/tutorial003.py!}
```
🔜 🏗 🗄 🔗 💖:
```JSON hl_lines="5-7"
{
"openapi": "3.0.2",
// More stuff here
"servers": [
{
"url": "/api/v1"
},
{
"url": "https://stag.example.com",
"description": "Staging environment"
},
{
"url": "https://prod.example.com",
"description": "Production environment"
}
],
"paths": {
// More stuff here
}
}
```
!!! tip
👀 🚘-🏗 💽 ⏮️ `url` 💲 `/api/v1`, ✊ ⚪️➡️ `root_path`.
🩺 🎚 <a href="http://127.0.0.1:9999/api/v1/docs" class="external-link" target="_blank">http://127.0.0.1:9999/api/v1/docs</a> ⚫️ 🔜 👀 💖:
<img src="/img/tutorial/behind-a-proxy/image03.png">
!!! tip
🩺 🎚 🔜 🔗 ⏮️ 💽 👈 👆 🖊.
### ❎ 🏧 💽 ⚪️➡️ `root_path`
🚥 👆 🚫 💚 **FastAPI** 🔌 🏧 💽 ⚙️ `root_path`, 👆 💪 ⚙️ 🔢 `root_path_in_servers=False`:
```Python hl_lines="9"
{!../../../docs_src/behind_a_proxy/tutorial004.py!}
```
&amp; ⤴️ ⚫️ 🏆 🚫 🔌 ⚫️ 🗄 🔗.
## 🗜 🎧-🈸
🚥 👆 💪 🗻 🎧-🈸 (🔬 [🎧 🈸 - 🗻](./sub-applications.md){.internal-link target=_blank}) ⏪ ⚙️ 🗳 ⏮️ `root_path`, 👆 💪 ⚫️ 🛎, 👆 🔜 ⌛.
FastAPI 🔜 🔘 ⚙️ `root_path` 🎆, ⚫️ 🔜 👷. 👶

58
docs/em/docs/advanced/conditional-openapi.md

@ -0,0 +1,58 @@
# 🎲 🗄
🚥 👆 💪, 👆 💪 ⚙️ ⚒ &amp; 🌐 🔢 🔗 🗄 ✔ ⚓️ 🔛 🌐, &amp; ❎ ⚫️ 🍕.
## 🔃 💂‍♂, 🔗, &amp; 🩺
🕵‍♂ 👆 🧾 👩‍💻 🔢 🏭 *🚫🔜 🚫* 🌌 🛡 👆 🛠️.
👈 🚫 🚮 🙆 ➕ 💂‍♂ 👆 🛠️, *➡ 🛠️* 🔜 💪 🌐❔ 👫.
🚥 📤 💂‍♂ ⚠ 👆 📟, ⚫️ 🔜 🔀.
🕵‍♂ 🧾 ⚒ ⚫️ 🌅 ⚠ 🤔 ❔ 🔗 ⏮️ 👆 🛠️, &amp; 💪 ⚒ ⚫️ 🌅 ⚠ 👆 ℹ ⚫️ 🏭. ⚫️ 💪 🤔 🎯 📨 <a href="https://en.wikipedia.org/wiki/Security_through_obscurity" class="external-link" target="_blank">💂‍♂ 🔘 🌌</a>.
🚥 👆 💚 🔐 👆 🛠️, 📤 📚 👍 👜 👆 💪, 🖼:
* ⚒ 💭 👆 ✔️ 👍 🔬 Pydantic 🏷 👆 📨 💪 &amp; 📨.
* 🔗 🙆 ✔ ✔ &amp; 🔑 ⚙️ 🔗.
* 🙅 🏪 🔢 🔐, 🕴 🔐#️⃣.
* 🛠️ &amp; ⚙️ 👍-💭 🔐 🧰, 💖 🇸🇲 &amp; 🥙 🤝, ♒️.
* 🚮 🌅 🧽 ✔ 🎛 ⏮️ Oauth2️⃣ ↔ 🌐❔ 💪.
* ...♒️.
👐, 👆 5️⃣📆 ✔️ 📶 🎯 ⚙️ 💼 🌐❔ 👆 🤙 💪 ❎ 🛠️ 🩺 🌐 (✅ 🏭) ⚖️ ⚓️ 🔛 📳 ⚪️➡️ 🌐 🔢.
## 🎲 🗄 ⚪️➡️ ⚒ &amp; 🇨🇻 {
👆 💪 💪 ⚙️ 🎏 Pydantic ⚒ 🔗 👆 🏗 🗄 &amp; 🩺 ⚜.
🖼:
```Python hl_lines="6 11"
{!../../../docs_src/conditional_openapi/tutorial001.py!}
```
📥 👥 📣 ⚒ `openapi_url` ⏮️ 🎏 🔢 `"/openapi.json"`.
&amp; ⤴️ 👥 ⚙️ ⚫️ 🕐❔ 🏗 `FastAPI` 📱.
⤴️ 👆 💪 ❎ 🗄 (✅ 🎚 🩺) ⚒ 🌐 🔢 `OPENAPI_URL` 🛁 🎻, 💖:
<div class="termy">
```console
$ OPENAPI_URL= uvicorn main:app
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
⤴️ 🚥 👆 🚶 📛 `/openapi.json`, `/docs`, ⚖️ `/redoc` 👆 🔜 🤚 `404 Not Found` ❌ 💖:
```JSON
{
"detail": "Not Found"
}
```

109
docs/em/docs/advanced/custom-request-and-route.md

@ -0,0 +1,109 @@
# 🛃 📨 &amp; APIRoute 🎓
💼, 👆 5️⃣📆 💚 🔐 ⚛ ⚙️ `Request` &amp; `APIRoute` 🎓.
🎯, 👉 5️⃣📆 👍 🎛 ⚛ 🛠️.
🖼, 🚥 👆 💚 ✍ ⚖️ 🔬 📨 💪 ⏭ ⚫️ 🛠️ 👆 🈸.
!!! danger
👉 "🏧" ⚒.
🚥 👆 ▶️ ⏮️ **FastAPI** 👆 💪 💚 🚶 👉 📄.
## ⚙️ 💼
⚙️ 💼 🔌:
* 🏭 🚫-🎻 📨 💪 🎻 (✅ <a href="https://msgpack.org/index.html" class="external-link" target="_blank">`msgpack`</a>).
* 🗜 🗜-🗜 📨 💪.
* 🔁 🚨 🌐 📨 💪.
## 🚚 🛃 📨 💪 🔢
➡️ 👀 ❔ ⚒ ⚙️ 🛃 `Request` 🏿 🗜 🗜 📨.
&amp; `APIRoute` 🏿 ⚙️ 👈 🛃 📨 🎓.
### ✍ 🛃 `GzipRequest` 🎓
!!! tip
👉 🧸 🖼 🎦 ❔ ⚫️ 👷, 🚥 👆 💪 🗜 🐕‍🦺, 👆 💪 ⚙️ 🚚 [`GzipMiddleware`](./middleware.md#gzipmiddleware){.internal-link target=_blank}.
🥇, 👥 ✍ `GzipRequest` 🎓, ❔ 🔜 📁 `Request.body()` 👩‍🔬 🗜 💪 🔍 ☑ 🎚.
🚥 📤 🙅‍♂ `gzip` 🎚, ⚫️ 🔜 🚫 🔄 🗜 💪.
👈 🌌, 🎏 🛣 🎓 💪 🍵 🗜 🗜 ⚖️ 🗜 📨.
```Python hl_lines="8-15"
{!../../../docs_src/custom_request_and_route/tutorial001.py!}
```
### ✍ 🛃 `GzipRoute` 🎓
⏭, 👥 ✍ 🛃 🏿 `fastapi.routing.APIRoute` 👈 🔜 ⚒ ⚙️ `GzipRequest`.
👉 🕰, ⚫️ 🔜 📁 👩‍🔬 `APIRoute.get_route_handler()`.
👉 👩‍🔬 📨 🔢. &amp; 👈 🔢 ⚫️❔ 🔜 📨 📨 &amp; 📨 📨.
📥 👥 ⚙️ ⚫️ ✍ `GzipRequest` ⚪️➡️ ⏮️ 📨.
```Python hl_lines="18-26"
{!../../../docs_src/custom_request_and_route/tutorial001.py!}
```
!!! note "📡 ℹ"
`Request` ✔️ `request.scope` 🔢, 👈 🐍 `dict` ⚗ 🗃 🔗 📨.
`Request` ✔️ `request.receive`, 👈 🔢 "📨" 💪 📨.
`scope` `dict` &amp; `receive` 🔢 👯‍♂️ 🍕 🔫 🔧.
&amp; 👈 2️⃣ 👜, `scope` &amp; `receive`, ⚫️❔ 💪 ✍ 🆕 `Request` 👐.
💡 🌅 🔃 `Request`<a href="https://www.starlette.io/requests/" class="external-link" target="_blank">💃 🩺 🔃 📨</a>.
🕴 👜 🔢 📨 `GzipRequest.get_route_handler` 🔨 🎏 🗜 `Request` `GzipRequest`.
🔨 👉, 👆 `GzipRequest` 🔜 ✊ 💅 🗜 📊 (🚥 💪) ⏭ 🚶‍♀️ ⚫️ 👆 *➡ 🛠️*.
⏮️ 👈, 🌐 🏭 ⚛ 🎏.
✋️ ↩️ 👆 🔀 `GzipRequest.body`, 📨 💪 🔜 🔁 🗜 🕐❔ ⚫️ 📐 **FastAPI** 🕐❔ 💪.
## 🔐 📨 💪 ⚠ 🐕‍🦺
!!! tip
❎ 👉 🎏 ⚠, ⚫️ 🎲 📚 ⏩ ⚙️ `body` 🛃 🐕‍🦺 `RequestValidationError` ([🚚 ❌](../tutorial/handling-errors.md#use-the-requestvalidationerror-body){.internal-link target=_blank}).
✋️ 👉 🖼 ☑ &amp; ⚫️ 🎦 ❔ 🔗 ⏮️ 🔗 🦲.
👥 💪 ⚙️ 👉 🎏 🎯 🔐 📨 💪 ⚠ 🐕‍🦺.
🌐 👥 💪 🍵 📨 🔘 `try`/`except` 🍫:
```Python hl_lines="13 15"
{!../../../docs_src/custom_request_and_route/tutorial002.py!}
```
🚥 ⚠ 📉, `Request` 👐 🔜 ↔, 👥 💪 ✍ &amp; ⚒ ⚙️ 📨 💪 🕐❔ 🚚 ❌:
```Python hl_lines="16-18"
{!../../../docs_src/custom_request_and_route/tutorial002.py!}
```
## 🛃 `APIRoute` 🎓 📻
👆 💪 ⚒ `route_class` 🔢 `APIRouter`:
```Python hl_lines="26"
{!../../../docs_src/custom_request_and_route/tutorial003.py!}
```
👉 🖼, *➡ 🛠️* 🔽 `router` 🔜 ⚙️ 🛃 `TimedRoute` 🎓, &amp; 🔜 ✔️ ➕ `X-Response-Time` 🎚 📨 ⏮️ 🕰 ⚫️ ✊ 🏗 📨:
```Python hl_lines="13-20"
{!../../../docs_src/custom_request_and_route/tutorial003.py!}
```

300
docs/em/docs/advanced/custom-response.md

@ -0,0 +1,300 @@
# 🛃 📨 - 🕸, 🎏, 📁, 🎏
🔢, **FastAPI** 🔜 📨 📨 ⚙️ `JSONResponse`.
👆 💪 🔐 ⚫️ 🛬 `Response` 🔗 👀 [📨 📨 🔗](response-directly.md){.internal-link target=_blank}.
✋️ 🚥 👆 📨 `Response` 🔗, 📊 🏆 🚫 🔁 🗜, &amp; 🧾 🏆 🚫 🔁 🏗 (🖼, 🔌 🎯 "📻 🆎", 🇺🇸🔍 🎚 `Content-Type` 🍕 🏗 🗄).
✋️ 👆 💪 📣 `Response` 👈 👆 💚 ⚙️, *➡ 🛠️ 👨‍🎨*.
🎚 👈 👆 📨 ⚪️➡️ 👆 *➡ 🛠️ 🔢* 🔜 🚮 🔘 👈 `Response`.
&amp; 🚥 👈 `Response` ✔️ 🎻 📻 🆎 (`application/json`), 💖 💼 ⏮️ `JSONResponse` &amp; `UJSONResponse`, 💽 👆 📨 🔜 🔁 🗜 (&amp; ⛽) ⏮️ 🙆 Pydantic `response_model` 👈 👆 📣 *➡ 🛠️ 👨‍🎨*.
!!! note
🚥 👆 ⚙️ 📨 🎓 ⏮️ 🙅‍♂ 📻 🆎, FastAPI 🔜 ⌛ 👆 📨 ✔️ 🙅‍♂ 🎚, ⚫️ 🔜 🚫 📄 📨 📁 🚮 🏗 🗄 🩺.
## ⚙️ `ORJSONResponse`
🖼, 🚥 👆 ✊ 🎭, 👆 💪 ❎ &amp; ⚙️ <a href="https://github.com/ijl/orjson" class="external-link" target="_blank">`orjson`</a> &amp; ⚒ 📨 `ORJSONResponse`.
🗄 `Response` 🎓 (🎧-🎓) 👆 💚 ⚙️ &amp; 📣 ⚫️ *➡ 🛠️ 👨‍🎨*.
⭕ 📨, 📨 `Response` 🔗 🌅 ⏩ 🌘 🛬 📖.
👉 ↩️ 🔢, FastAPI 🔜 ✔ 🔠 🏬 🔘 &amp; ⚒ 💭 ⚫️ 🎻 ⏮️ 🎻, ⚙️ 🎏 [🎻 🔗 🔢](../tutorial/encoder.md){.internal-link target=_blank} 🔬 🔰. 👉 ⚫️❔ ✔ 👆 📨 **❌ 🎚**, 🖼 💽 🏷.
✋️ 🚥 👆 🎯 👈 🎚 👈 👆 🛬 **🎻 ⏮️ 🎻**, 👆 💪 🚶‍♀️ ⚫️ 🔗 📨 🎓 &amp; ❎ ➕ 🌥 👈 FastAPI 🔜 ✔️ 🚶‍♀️ 👆 📨 🎚 🔘 `jsonable_encoder` ⏭ 🚶‍♀️ ⚫️ 📨 🎓.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001b.py!}
```
!!! info
🔢 `response_class` 🔜 ⚙️ 🔬 "📻 🆎" 📨.
👉 💼, 🇺🇸🔍 🎚 `Content-Type` 🔜 ⚒ `application/json`.
&amp; ⚫️ 🔜 📄 ✅ 🗄.
!!! tip
`ORJSONResponse` ⏳ 🕴 💪 FastAPI, 🚫 💃.
## 🕸 📨
📨 📨 ⏮️ 🕸 🔗 ⚪️➡️ **FastAPI**, ⚙️ `HTMLResponse`.
* 🗄 `HTMLResponse`.
* 🚶‍♀️ `HTMLResponse` 🔢 `response_class` 👆 *➡ 🛠️ 👨‍🎨*.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial002.py!}
```
!!! info
🔢 `response_class` 🔜 ⚙️ 🔬 "📻 🆎" 📨.
👉 💼, 🇺🇸🔍 🎚 `Content-Type` 🔜 ⚒ `text/html`.
&amp; ⚫️ 🔜 📄 ✅ 🗄.
### 📨 `Response`
👀 [📨 📨 🔗](response-directly.md){.internal-link target=_blank}, 👆 💪 🔐 📨 🔗 👆 *➡ 🛠️*, 🛬 ⚫️.
🎏 🖼 ⚪️➡️ 🔛, 🛬 `HTMLResponse`, 💪 👀 💖:
```Python hl_lines="2 7 19"
{!../../../docs_src/custom_response/tutorial003.py!}
```
!!! warning
`Response` 📨 🔗 👆 *➡ 🛠️ 🔢* 🏆 🚫 📄 🗄 (🖼, `Content-Type` 🏆 🚫 📄) &amp; 🏆 🚫 ⭐ 🏧 🎓 🩺.
!!! info
↗️, ☑ `Content-Type` 🎚, 👔 📟, ♒️, 🔜 👟 ⚪️➡️ `Response` 🎚 👆 📨.
### 📄 🗄 &amp; 🔐 `Response`
🚥 👆 💚 🔐 📨 ⚪️➡️ 🔘 🔢 ✋️ 🎏 🕰 📄 "📻 🆎" 🗄, 👆 💪 ⚙️ `response_class` 🔢 &amp; 📨 `Response` 🎚.
`response_class` 🔜 ⤴️ ⚙️ 🕴 📄 🗄 *➡ 🛠️*, ✋️ 👆 `Response` 🔜 ⚙️.
#### 📨 `HTMLResponse` 🔗
🖼, ⚫️ 💪 🕳 💖:
```Python hl_lines="7 21 23"
{!../../../docs_src/custom_response/tutorial004.py!}
```
👉 🖼, 🔢 `generate_html_response()` ⏪ 🏗 &amp; 📨 `Response` ↩️ 🛬 🕸 `str`.
🛬 🏁 🤙 `generate_html_response()`, 👆 ⏪ 🛬 `Response` 👈 🔜 🔐 🔢 **FastAPI** 🎭.
✋️ 👆 🚶‍♀️ `HTMLResponse` `response_class` 💁‍♂️, **FastAPI** 🔜 💭 ❔ 📄 ⚫️ 🗄 &amp; 🎓 🩺 🕸 ⏮️ `text/html`:
<img src="/img/tutorial/custom-response/image01.png">
## 💪 📨
📥 💪 📨.
✔️ 🤯 👈 👆 💪 ⚙️ `Response` 📨 🕳 🙆, ⚖️ ✍ 🛃 🎧-🎓.
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.responses import HTMLResponse`.
**FastAPI** 🚚 🎏 `starlette.responses` `fastapi.responses` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃.
### `Response`
👑 `Response` 🎓, 🌐 🎏 📨 😖 ⚪️➡️ ⚫️.
👆 💪 📨 ⚫️ 🔗.
⚫️ 🚫 📄 🔢:
* `content` - `str` ⚖️ `bytes`.
* `status_code` - `int` 🇺🇸🔍 👔 📟.
* `headers` - `dict` 🎻.
* `media_type` - `str` 🤝 📻 🆎. 🤶 Ⓜ. `"text/html"`.
FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎 🎚, ⚓️ 🔛 = &amp; 🔁 = ✍ 🆎.
```Python hl_lines="1 18"
{!../../../docs_src/response_directly/tutorial002.py!}
```
### `HTMLResponse`
✊ ✍ ⚖️ 🔢 &amp; 📨 🕸 📨, 👆 ✍ 🔛.
### `PlainTextResponse`
✊ ✍ ⚖️ 🔢 &amp; 📨 ✅ ✍ 📨.
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial005.py!}
```
### `JSONResponse`
✊ 💽 &amp; 📨 `application/json` 🗜 📨.
👉 🔢 📨 ⚙️ **FastAPI**, 👆 ✍ 🔛.
### `ORJSONResponse`
⏩ 🎛 🎻 📨 ⚙️ <a href="https://github.com/ijl/orjson" class="external-link" target="_blank">`orjson`</a>, 👆 ✍ 🔛.
### `UJSONResponse`
🎛 🎻 📨 ⚙️ <a href="https://github.com/ultrajson/ultrajson" class="external-link" target="_blank">`ujson`</a>.
!!! warning
`ujson` 🌘 💛 🌘 🐍 🏗-🛠️ ❔ ⚫️ 🍵 📐-💼.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001.py!}
```
!!! tip
⚫️ 💪 👈 `ORJSONResponse` 💪 ⏩ 🎛.
### `RedirectResponse`
📨 🇺🇸🔍 ❎. ⚙️ 3️⃣0️⃣7️⃣ 👔 📟 (🍕 ❎) 🔢.
👆 💪 📨 `RedirectResponse` 🔗:
```Python hl_lines="2 9"
{!../../../docs_src/custom_response/tutorial006.py!}
```
---
⚖️ 👆 💪 ⚙️ ⚫️ `response_class` 🔢:
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial006b.py!}
```
🚥 👆 👈, ⤴️ 👆 💪 📨 📛 🔗 ⚪️➡️ 👆 *➡ 🛠️* 🔢.
👉 💼, `status_code` ⚙️ 🔜 🔢 1️⃣ `RedirectResponse`, ❔ `307`.
---
👆 💪 ⚙️ `status_code` 🔢 🌀 ⏮️ `response_class` 🔢:
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial006c.py!}
```
### `StreamingResponse`
✊ 🔁 🚂 ⚖️ 😐 🚂/🎻 &amp; 🎏 📨 💪.
```Python hl_lines="2 14"
{!../../../docs_src/custom_response/tutorial007.py!}
```
#### ⚙️ `StreamingResponse` ⏮️ 📁-💖 🎚
🚥 👆 ✔️ 📁-💖 🎚 (✅ 🎚 📨 `open()`), 👆 💪 ✍ 🚂 🔢 🔁 🤭 👈 📁-💖 🎚.
👈 🌌, 👆 🚫 ✔️ ✍ ⚫️ 🌐 🥇 💾, &amp; 👆 💪 🚶‍♀️ 👈 🚂 🔢 `StreamingResponse`, &amp; 📨 ⚫️.
👉 🔌 📚 🗃 🔗 ⏮️ ☁ 💾, 📹 🏭, &amp; 🎏.
```{ .python .annotate hl_lines="2 10-12 14" }
{!../../../docs_src/custom_response/tutorial008.py!}
```
1️⃣. 👉 🚂 🔢. ⚫️ "🚂 🔢" ↩️ ⚫️ 🔌 `yield` 📄 🔘.
2️⃣. ⚙️ `with` 🍫, 👥 ⚒ 💭 👈 📁-💖 🎚 📪 ⏮️ 🚂 🔢 🔨. , ⏮️ ⚫️ 🏁 📨 📨.
3️⃣. 👉 `yield from` 💬 🔢 🔁 🤭 👈 👜 🌟 `file_like`. &amp; ⤴️, 🔠 🍕 🔁, 🌾 👈 🍕 👟 ⚪️➡️ 👉 🚂 🔢.
, ⚫️ 🚂 🔢 👈 📨 "🏭" 👷 🕳 🙆 🔘.
🔨 ⚫️ 👉 🌌, 👥 💪 🚮 ⚫️ `with` 🍫, &amp; 👈 🌌, 🚚 👈 ⚫️ 📪 ⏮️ 🏁.
!!! tip
👀 👈 📥 👥 ⚙️ 🐩 `open()` 👈 🚫 🐕‍🦺 `async` &amp; `await`, 👥 📣 ➡ 🛠️ ⏮️ 😐 `def`.
### `FileResponse`
🔁 🎏 📁 📨.
✊ 🎏 ⚒ ❌ 🔗 🌘 🎏 📨 🆎:
* `path` - 📁 📁 🎏.
* `headers` - 🙆 🛃 🎚 🔌, 📖.
* `media_type` - 🎻 🤝 📻 🆎. 🚥 🔢, 📁 ⚖️ ➡ 🔜 ⚙️ 🔑 📻 🆎.
* `filename` - 🚥 ⚒, 👉 🔜 🔌 📨 `Content-Disposition`.
📁 📨 🔜 🔌 ☑ `Content-Length`, `Last-Modified` &amp; `ETag` 🎚.
```Python hl_lines="2 10"
{!../../../docs_src/custom_response/tutorial009.py!}
```
👆 💪 ⚙️ `response_class` 🔢:
```Python hl_lines="2 8 10"
{!../../../docs_src/custom_response/tutorial009b.py!}
```
👉 💼, 👆 💪 📨 📁 ➡ 🔗 ⚪️➡️ 👆 *➡ 🛠️* 🔢.
## 🛃 📨 🎓
👆 💪 ✍ 👆 👍 🛃 📨 🎓, 😖 ⚪️➡️ `Response` &amp; ⚙️ ⚫️.
🖼, ➡️ 💬 👈 👆 💚 ⚙️ <a href="https://github.com/ijl/orjson" class="external-link" target="_blank">`orjson`</a>, ✋️ ⏮️ 🛃 ⚒ 🚫 ⚙️ 🔌 `ORJSONResponse` 🎓.
➡️ 💬 👆 💚 ⚫️ 📨 🔂 &amp; 📁 🎻, 👆 💚 ⚙️ Orjson 🎛 `orjson.OPT_INDENT_2`.
👆 💪 ✍ `CustomORJSONResponse`. 👑 👜 👆 ✔️ ✍ `Response.render(content)` 👩‍🔬 👈 📨 🎚 `bytes`:
```Python hl_lines="9-14 17"
{!../../../docs_src/custom_response/tutorial009c.py!}
```
🔜 ↩️ 🛬:
```json
{"message": "Hello World"}
```
...👉 📨 🔜 📨:
```json
{
"message": "Hello World"
}
```
↗️, 👆 🔜 🎲 🔎 🌅 👍 🌌 ✊ 📈 👉 🌘 ❕ 🎻. 👶
## 🔢 📨 🎓
🕐❔ 🏗 **FastAPI** 🎓 👐 ⚖️ `APIRouter` 👆 💪 ✔ ❔ 📨 🎓 ⚙️ 🔢.
🔢 👈 🔬 👉 `default_response_class`.
🖼 🔛, **FastAPI** 🔜 ⚙️ `ORJSONResponse` 🔢, 🌐 *➡ 🛠️*, ↩️ `JSONResponse`.
```Python hl_lines="2 4"
{!../../../docs_src/custom_response/tutorial010.py!}
```
!!! tip
👆 💪 🔐 `response_class` *➡ 🛠️* ⏭.
## 🌖 🧾
👆 💪 📣 📻 🆎 &amp; 📚 🎏 ℹ 🗄 ⚙️ `responses`: [🌖 📨 🗄](additional-responses.md){.internal-link target=_blank}.

98
docs/em/docs/advanced/dataclasses.md

@ -0,0 +1,98 @@
# ⚙️ 🎻
FastAPI 🏗 🔛 🔝 **Pydantic**, &amp; 👤 ✔️ 🌏 👆 ❔ ⚙️ Pydantic 🏷 📣 📨 &amp; 📨.
✋️ FastAPI 🐕‍🦺 ⚙️ <a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a> 🎏 🌌:
```Python hl_lines="1 7-12 19-20"
{!../../../docs_src/dataclasses/tutorial001.py!}
```
👉 🐕‍🦺 👏 **Pydantic**, ⚫️ ✔️ <a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">🔗 🐕‍🦺 `dataclasses`</a>.
, ⏮️ 📟 🔛 👈 🚫 ⚙️ Pydantic 🎯, FastAPI ⚙️ Pydantic 🗜 📚 🐩 🎻 Pydantic 👍 🍛 🎻.
&amp; ↗️, ⚫️ 🐕‍🦺 🎏:
* 💽 🔬
* 💽 🛠️
* 💽 🧾, ♒️.
👉 👷 🎏 🌌 ⏮️ Pydantic 🏷. &amp; ⚫️ 🤙 🏆 🎏 🌌 🔘, ⚙️ Pydantic.
!!! info
✔️ 🤯 👈 🎻 💪 🚫 🌐 Pydantic 🏷 💪.
, 👆 5️⃣📆 💪 ⚙️ Pydantic 🏷.
✋️ 🚥 👆 ✔️ 📚 🎻 🤥 🤭, 👉 👌 🎱 ⚙️ 👫 🏋️ 🕸 🛠️ ⚙️ FastAPI. 👶
## 🎻 `response_model`
👆 💪 ⚙️ `dataclasses` `response_model` 🔢:
```Python hl_lines="1 7-13 19"
{!../../../docs_src/dataclasses/tutorial002.py!}
```
🎻 🔜 🔁 🗜 Pydantic 🎻.
👉 🌌, 🚮 🔗 🔜 🎦 🆙 🛠️ 🩺 👩‍💻 🔢:
<img src="/img/tutorial/dataclasses/image01.png">
## 🎻 🔁 📊 📊
👆 💪 🌀 `dataclasses` ⏮️ 🎏 🆎 ✍ ⚒ 🐦 📊 📊.
💼, 👆 💪 ✔️ ⚙️ Pydantic ⏬ `dataclasses`. 🖼, 🚥 👆 ✔️ ❌ ⏮️ 🔁 🏗 🛠️ 🧾.
👈 💼, 👆 💪 🎯 💱 🐩 `dataclasses` ⏮️ `pydantic.dataclasses`, ❔ 💧-♻:
```{ .python .annotate hl_lines="1 5 8-11 14-17 23-25 28" }
{!../../../docs_src/dataclasses/tutorial003.py!}
```
1️⃣. 👥 🗄 `field` ⚪️➡️ 🐩 `dataclasses`.
2️⃣. `pydantic.dataclasses` 💧-♻ `dataclasses`.
3️⃣. `Author` 🎻 🔌 📇 `Item` 🎻.
4️⃣. `Author` 🎻 ⚙️ `response_model` 🔢.
5️⃣. 👆 💪 ⚙️ 🎏 🐩 🆎 ✍ ⏮️ 🎻 📨 💪.
👉 💼, ⚫️ 📇 `Item` 🎻.
6️⃣. 📥 👥 🛬 📖 👈 🔌 `items` ❔ 📇 🎻.
FastAPI 🎯 <abbr title="converting the data to a format that can be transmitted"></abbr> 💽 🎻.
7️⃣. 📥 `response_model` ⚙️ 🆎 ✍ 📇 `Author` 🎻.
🔄, 👆 💪 🌀 `dataclasses` ⏮️ 🐩 🆎 ✍.
8️⃣. 👀 👈 👉 *➡ 🛠️ 🔢* ⚙️ 🥔 `def` ↩️ `async def`.
🕧, FastAPI 👆 💪 🌀 `def` &amp; `async def` 💪.
🚥 👆 💪 ↗️ 🔃 🕐❔ ⚙️ ❔, ✅ 👅 📄 _"🏃 ❓" _ 🩺 🔃 <a href="https://fastapi.tiangolo.com/async/#in-a-hurry" target="_blank" class="internal-link">`async` &amp; `await`</a>.
9️⃣. 👉 *➡ 🛠️ 🔢* 🚫 🛬 🎻 (👐 ⚫️ 💪), ✋️ 📇 📖 ⏮️ 🔗 💽.
FastAPI 🔜 ⚙️ `response_model` 🔢 (👈 🔌 🎻) 🗜 📨.
👆 💪 🌀 `dataclasses` ⏮️ 🎏 🆎 ✍ 📚 🎏 🌀 📨 🏗 📊 📊.
✅-📟 ✍ 💁‍♂ 🔛 👀 🌅 🎯 ℹ.
## 💡 🌅
👆 💪 🌀 `dataclasses` ⏮️ 🎏 Pydantic 🏷, 😖 ⚪️➡️ 👫, 🔌 👫 👆 👍 🏷, ♒️.
💡 🌅, ✅ <a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/" class="external-link" target="_blank">Pydantic 🩺 🔃 🎻</a>.
## ⏬
👉 💪 ↩️ FastAPI ⏬ `0.67.0`. 👶

160
docs/em/docs/advanced/events.md

@ -0,0 +1,160 @@
# 🔆 🎉
👆 💪 🔬 ⚛ (📟) 👈 🔜 🛠️ ⏭ 🈸 **▶️ 🆙**. 👉 ⛓ 👈 👉 📟 🔜 🛠️ **🕐**, **⏭** 🈸 **▶️ 📨 📨**.
🎏 🌌, 👆 💪 🔬 ⚛ (📟) 👈 🔜 🛠️ 🕐❔ 🈸 **🤫 🔽**. 👉 💼, 👉 📟 🔜 🛠️ **🕐**, **⏮️** ✔️ 🍵 🎲 **📚 📨**.
↩️ 👉 📟 🛠️ ⏭ 🈸 **▶️** ✊ 📨, &amp; ▶️️ ⏮️ ⚫️ **🏁** 🚚 📨, ⚫️ 📔 🎂 🈸 **🔆** (🔤 "🔆" 🔜 ⚠ 🥈 👶).
👉 💪 📶 ⚠ ⚒ 🆙 **ℹ** 👈 👆 💪 ⚙️ 🎂 📱, &amp; 👈 **💰** 👪 📨, &amp;/⚖️ 👈 👆 💪 **🧹 🆙** ⏮️. 🖼, 💽 🔗 🎱, ⚖️ 🚚 🔗 🎰 🏫 🏷.
## ⚙️ 💼
➡️ ▶️ ⏮️ 🖼 **⚙️ 💼** &amp; ⤴️ 👀 ❔ ❎ ⚫️ ⏮️ 👉.
➡️ 🌈 👈 👆 ✔️ **🎰 🏫 🏷** 👈 👆 💚 ⚙️ 🍵 📨. 👶
🎏 🏷 🔗 👪 📨,, ⚫️ 🚫 1️⃣ 🏷 📍 📨, ⚖️ 1️⃣ 📍 👩‍💻 ⚖️ 🕳 🎏.
➡️ 🌈 👈 🚚 🏷 💪 **✊ 🕰**, ↩️ ⚫️ ✔️ ✍ 📚 **💽 ⚪️➡️ 💾**. 👆 🚫 💚 ⚫️ 🔠 📨.
👆 💪 📐 ⚫️ 🔝 🎚 🕹/📁, ✋️ 👈 🔜 ⛓ 👈 ⚫️ 🔜 **📐 🏷** 🚥 👆 🏃‍♂ 🙅 🏧 💯, ⤴️ 👈 💯 🔜 **🐌** ↩️ ⚫️ 🔜 ✔️ ⌛ 🏷 📐 ⏭ 💆‍♂ 💪 🏃 🔬 🍕 📟.
👈 ⚫️❔ 👥 🔜 ❎, ➡️ 📐 🏷 ⏭ 📨 🍵, ✋️ 🕴 ▶️️ ⏭ 🈸 ▶️ 📨 📨, 🚫 ⏪ 📟 ➖ 📐.
## 🔆
👆 💪 🔬 👉 *🕴* &amp; *🤫* ⚛ ⚙️ `lifespan` 🔢 `FastAPI` 📱, &amp; "🔑 👨‍💼" (👤 🔜 🎦 👆 ⚫️❔ 👈 🥈).
➡️ ▶️ ⏮️ 🖼 &amp; ⤴️ 👀 ⚫️ ℹ.
👥 ✍ 🔁 🔢 `lifespan()` ⏮️ `yield` 💖 👉:
```Python hl_lines="16 19"
{!../../../docs_src/events/tutorial003.py!}
```
📥 👥 ⚖ 😥 *🕴* 🛠️ 🚚 🏷 🚮 (❌) 🏷 🔢 📖 ⏮️ 🎰 🏫 🏷 ⏭ `yield`. 👉 📟 🔜 🛠️ **⏭** 🈸 **▶️ ✊ 📨**, ⏮️ *🕴*.
&amp; ⤴️, ▶️️ ⏮️ `yield`, 👥 🚚 🏷. 👉 📟 🔜 🛠️ **⏮️** 🈸 **🏁 🚚 📨**, ▶️️ ⏭ *🤫*. 👉 💪, 🖼, 🚀 ℹ 💖 💾 ⚖️ 💻.
!!! tip
`shutdown` 🔜 🔨 🕐❔ 👆 **⛔️** 🈸.
🎲 👆 💪 ▶️ 🆕 ⏬, ⚖️ 👆 🤚 🎡 🏃 ⚫️. 🤷
### 🔆 🔢
🥇 👜 👀, 👈 👥 ⚖ 🔁 🔢 ⏮️ `yield`. 👉 📶 🎏 🔗 ⏮️ `yield`.
```Python hl_lines="14-19"
{!../../../docs_src/events/tutorial003.py!}
```
🥇 🍕 🔢, ⏭ `yield`, 🔜 🛠️ **⏭** 🈸 ▶️.
&amp; 🍕 ⏮️ `yield` 🔜 🛠️ **⏮️** 🈸 ✔️ 🏁.
### 🔁 🔑 👨‍💼
🚥 👆 ✅, 🔢 🎀 ⏮️ `@asynccontextmanager`.
👈 🗜 🔢 🔘 🕳 🤙 "**🔁 🔑 👨‍💼**".
```Python hl_lines="1 13"
{!../../../docs_src/events/tutorial003.py!}
```
**🔑 👨‍💼** 🐍 🕳 👈 👆 💪 ⚙️ `with` 📄, 🖼, `open()` 💪 ⚙️ 🔑 👨‍💼:
```Python
with open("file.txt") as file:
file.read()
```
⏮️ ⏬ 🐍, 📤 **🔁 🔑 👨‍💼**. 👆 🔜 ⚙️ ⚫️ ⏮️ `async with`:
```Python
async with lifespan(app):
await do_stuff()
```
🕐❔ 👆 ✍ 🔑 👨‍💼 ⚖️ 🔁 🔑 👨‍💼 💖 🔛, ⚫️❔ ⚫️ 🔨 👈, ⏭ 🛬 `with` 🍫, ⚫️ 🔜 🛠️ 📟 ⏭ `yield`, &amp; ⏮️ ❎ `with` 🍫, ⚫️ 🔜 🛠️ 📟 ⏮️ `yield`.
👆 📟 🖼 🔛, 👥 🚫 ⚙️ ⚫️ 🔗, ✋️ 👥 🚶‍♀️ ⚫️ FastAPI ⚫️ ⚙️ ⚫️.
`lifespan` 🔢 `FastAPI` 📱 ✊ **🔁 🔑 👨‍💼**, 👥 💪 🚶‍♀️ 👆 🆕 `lifespan` 🔁 🔑 👨‍💼 ⚫️.
```Python hl_lines="22"
{!../../../docs_src/events/tutorial003.py!}
```
## 🎛 🎉 (😢)
!!! warning
👍 🌌 🍵 *🕴* &amp; *🤫* ⚙️ `lifespan` 🔢 `FastAPI` 📱 🔬 🔛.
👆 💪 🎲 🚶 👉 🍕.
📤 🎛 🌌 🔬 👉 ⚛ 🛠️ ⏮️ *🕴* &amp; ⏮️ *🤫*.
👆 💪 🔬 🎉 🐕‍🦺 (🔢) 👈 💪 🛠️ ⏭ 🈸 ▶️ 🆙, ⚖️ 🕐❔ 🈸 🤫 🔽.
👫 🔢 💪 📣 ⏮️ `async def` ⚖️ 😐 `def`.
### `startup` 🎉
🚮 🔢 👈 🔜 🏃 ⏭ 🈸 ▶️, 📣 ⚫️ ⏮️ 🎉 `"startup"`:
```Python hl_lines="8"
{!../../../docs_src/events/tutorial001.py!}
```
👉 💼, `startup` 🎉 🐕‍🦺 🔢 🔜 🔢 🏬 "💽" ( `dict`) ⏮️ 💲.
👆 💪 🚮 🌅 🌘 1️⃣ 🎉 🐕‍🦺 🔢.
&amp; 👆 🈸 🏆 🚫 ▶️ 📨 📨 ⏭ 🌐 `startup` 🎉 🐕‍🦺 ✔️ 🏁.
### `shutdown` 🎉
🚮 🔢 👈 🔜 🏃 🕐❔ 🈸 🤫 🔽, 📣 ⚫️ ⏮️ 🎉 `"shutdown"`:
```Python hl_lines="6"
{!../../../docs_src/events/tutorial002.py!}
```
📥, `shutdown` 🎉 🐕‍🦺 🔢 🔜 ✍ ✍ ⏸ `"Application shutdown"` 📁 `log.txt`.
!!! info
`open()` 🔢, `mode="a"` ⛓ "🎻",, ⏸ 🔜 🚮 ⏮️ ⚫️❔ 🔛 👈 📁, 🍵 📁 ⏮️ 🎚.
!!! tip
👀 👈 👉 💼 👥 ⚙️ 🐩 🐍 `open()` 🔢 👈 🔗 ⏮️ 📁.
, ⚫️ 🔌 👤/🅾 (🔢/🔢), 👈 🚚 "⌛" 👜 ✍ 💾.
✋️ `open()` 🚫 ⚙️ `async` &amp; `await`.
, 👥 📣 🎉 🐕‍🦺 🔢 ⏮️ 🐩 `def` ↩️ `async def`.
!!! info
👆 💪 ✍ 🌅 🔃 👫 🎉 🐕‍🦺 <a href="https://www.starlette.io/events/" class="external-link" target="_blank">💃 🎉' 🩺</a>.
### `startup` &amp; `shutdown` 👯‍♂️
📤 ↕ 🤞 👈 ⚛ 👆 *🕴* &amp; *🤫* 🔗, 👆 💪 💚 ▶️ 🕳 &amp; ⤴️ 🏁 ⚫️, 📎 ℹ &amp; ⤴️ 🚀 ⚫️, ♒️.
🔨 👈 👽 🔢 👈 🚫 💰 ⚛ ⚖️ 🔢 👯‍♂️ 🌅 ⚠ 👆 🔜 💪 🏪 💲 🌐 🔢 ⚖️ 🎏 🎱.
↩️ 👈, ⚫️ 🔜 👍 ↩️ ⚙️ `lifespan` 🔬 🔛.
## 📡 ℹ
📡 ℹ 😟 🤓. 👶
🔘, 🔫 📡 🔧, 👉 🍕 <a href="https://asgi.readthedocs.io/en/latest/specs/lifespan.html" class="external-link" target="_blank">🔆 🛠️</a>, &amp; ⚫️ 🔬 🎉 🤙 `startup` &amp; `shutdown`.
## 🎧 🈸
👶 ✔️ 🤯 👈 👫 🔆 🎉 (🕴 &amp; 🤫) 🔜 🕴 🛠️ 👑 🈸, 🚫 [🎧 🈸 - 🗻](./sub-applications.md){.internal-link target=_blank}.

314
docs/em/docs/advanced/extending-openapi.md

@ -0,0 +1,314 @@
# ↔ 🗄
!!! warning
👉 👍 🏧 ⚒. 👆 🎲 💪 🚶 ⚫️.
🚥 👆 📄 🔰 - 👩‍💻 🦮, 👆 💪 🎲 🚶 👉 📄.
🚥 👆 ⏪ 💭 👈 👆 💪 🔀 🏗 🗄 🔗, 😣 👂.
📤 💼 🌐❔ 👆 💪 💪 🔀 🏗 🗄 🔗.
👉 📄 👆 🔜 👀 ❔.
## 😐 🛠️
😐 (🔢) 🛠️, ⏩.
`FastAPI` 🈸 (👐) ✔️ `.openapi()` 👩‍🔬 👈 📈 📨 🗄 🔗.
🍕 🈸 🎚 🏗, *➡ 🛠️* `/openapi.json` (⚖️ ⚫️❔ 👆 ⚒ 👆 `openapi_url`) ®.
⚫️ 📨 🎻 📨 ⏮️ 🏁 🈸 `.openapi()` 👩‍🔬.
🔢, ⚫️❔ 👩‍🔬 `.openapi()` 🔨 ✅ 🏠 `.openapi_schema` 👀 🚥 ⚫️ ✔️ 🎚 &amp; 📨 👫.
🚥 ⚫️ 🚫, ⚫️ 🏗 👫 ⚙️ 🚙 🔢 `fastapi.openapi.utils.get_openapi`.
&amp; 👈 🔢 `get_openapi()` 📨 🔢:
* `title`: 🗄 📛, 🎦 🩺.
* `version`: ⏬ 👆 🛠️, ✅ `2.5.0`.
* `openapi_version`: ⏬ 🗄 🔧 ⚙️. 🔢, ⏪: `3.0.2`.
* `description`: 📛 👆 🛠️.
* `routes`: 📇 🛣, 👫 🔠 ® *➡ 🛠️*. 👫 ✊ ⚪️➡️ `app.routes`.
## 🔑 🔢
⚙️ ℹ 🔛, 👆 💪 ⚙️ 🎏 🚙 🔢 🏗 🗄 🔗 &amp; 🔐 🔠 🍕 👈 👆 💪.
🖼, ➡️ 🚮 <a href="https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md#x-logo" class="external-link" target="_blank">📄 🗄 ↔ 🔌 🛃 🔱</a>.
### 😐 **FastAPI**
🥇, ✍ 🌐 👆 **FastAPI** 🈸 🛎:
```Python hl_lines="1 4 7-9"
{!../../../docs_src/extending_openapi/tutorial001.py!}
```
### 🏗 🗄 🔗
⤴️, ⚙️ 🎏 🚙 🔢 🏗 🗄 🔗, 🔘 `custom_openapi()` 🔢:
```Python hl_lines="2 15-20"
{!../../../docs_src/extending_openapi/tutorial001.py!}
```
### 🔀 🗄 🔗
🔜 👆 💪 🚮 📄 ↔, ❎ 🛃 `x-logo` `info` "🎚" 🗄 🔗:
```Python hl_lines="21-23"
{!../../../docs_src/extending_openapi/tutorial001.py!}
```
### 💾 🗄 🔗
👆 💪 ⚙️ 🏠 `.openapi_schema` "💾", 🏪 👆 🏗 🔗.
👈 🌌, 👆 🈸 🏆 🚫 ✔️ 🏗 🔗 🔠 🕰 👩‍💻 📂 👆 🛠️ 🩺.
⚫️ 🔜 🏗 🕴 🕐, &amp; ⤴️ 🎏 💾 🔗 🔜 ⚙️ ⏭ 📨.
```Python hl_lines="13-14 24-25"
{!../../../docs_src/extending_openapi/tutorial001.py!}
```
### 🔐 👩‍🔬
🔜 👆 💪 ❎ `.openapi()` 👩‍🔬 ⏮️ 👆 🆕 🔢.
```Python hl_lines="28"
{!../../../docs_src/extending_openapi/tutorial001.py!}
```
### ✅ ⚫️
🕐 👆 🚶 <a href="http://127.0.0.1:8000/redoc" class="external-link" target="_blank">http://127.0.0.1:8000/redoc</a> 👆 🔜 👀 👈 👆 ⚙️ 👆 🛃 🔱 (👉 🖼, **FastAPI**'Ⓜ 🔱):
<img src="/img/tutorial/extending-openapi/image01.png">
## 👤-🕸 🕸 &amp; 🎚 🩺
🛠️ 🩺 ⚙️ **🦁 🎚** &amp; **📄**, &amp; 🔠 👈 💪 🕸 &amp; 🎚 📁.
🔢, 👈 📁 🍦 ⚪️➡️ <abbr title="Content Delivery Network: A service, normally composed of several servers, that provides static files, like JavaScript and CSS. It's commonly used to serve those files from the server closer to the client, improving performance.">💲</abbr>.
✋️ ⚫️ 💪 🛃 ⚫️, 👆 💪 ⚒ 🎯 💲, ⚖️ 🍦 📁 👆.
👈 ⚠, 🖼, 🚥 👆 💪 👆 📱 🚧 👷 ⏪ 📱, 🍵 📂 🕸 🔐, ⚖️ 🇧🇿 🕸.
📥 👆 🔜 👀 ❔ 🍦 👈 📁 👆, 🎏 FastAPI 📱, &amp; 🔗 🩺 ⚙️ 👫.
### 🏗 📁 📊
➡️ 💬 👆 🏗 📁 📊 👀 💖 👉:
```
.
├── app
│ ├── __init__.py
│ ├── main.py
```
🔜 ✍ 📁 🏪 📚 🎻 📁.
👆 🆕 📁 📊 💪 👀 💖 👉:
```
.
├── app
│   ├── __init__.py
│   ├── main.py
└── static/
```
### ⏬ 📁
⏬ 🎻 📁 💪 🩺 &amp; 🚮 👫 🔛 👈 `static/` 📁.
👆 💪 🎲 ▶️️-🖊 🔠 🔗 &amp; 🖊 🎛 🎏 `Save link as...`.
**🦁 🎚** ⚙️ 📁:
* <a href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui-bundle.js" class="external-link" target="_blank">`swagger-ui-bundle.js`</a>
* <a href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui.css" class="external-link" target="_blank">`swagger-ui.css`</a>
&amp; **📄** ⚙️ 📁:
* <a href="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js" class="external-link" target="_blank">`redoc.standalone.js`</a>
⏮️ 👈, 👆 📁 📊 💪 👀 💖:
```
.
├── app
│   ├── __init__.py
│   ├── main.py
└── static
├── redoc.standalone.js
├── swagger-ui-bundle.js
└── swagger-ui.css
```
### 🍦 🎻 📁
* 🗄 `StaticFiles`.
* "🗻" `StaticFiles()` 👐 🎯 ➡.
```Python hl_lines="7 11"
{!../../../docs_src/extending_openapi/tutorial002.py!}
```
### 💯 🎻 📁
▶️ 👆 🈸 &amp; 🚶 <a href="http://127.0.0.1:8000/static/redoc.standalone.js" class="external-link" target="_blank">http://127.0.0.1:8000/static/redoc.standalone.js</a>.
👆 🔜 👀 📶 📏 🕸 📁 **📄**.
⚫️ 💪 ▶️ ⏮️ 🕳 💖:
```JavaScript
/*!
* ReDoc - OpenAPI/Swagger-generated API Reference Documentation
* -------------------------------------------------------------
* Version: "2.0.0-rc.18"
* Repo: https://github.com/Redocly/redoc
*/
!function(e,t){"object"==typeof exports&&"object"==typeof m
...
```
👈 ✔ 👈 👆 💆‍♂ 💪 🍦 🎻 📁 ⚪️➡️ 👆 📱, &amp; 👈 👆 🥉 🎻 📁 🩺 ☑ 🥉.
🔜 👥 💪 🔗 📱 ⚙️ 📚 🎻 📁 🩺.
### ❎ 🏧 🩺
🥇 🔁 ❎ 🏧 🩺, 📚 ⚙️ 💲 🔢.
❎ 👫, ⚒ 👫 📛 `None` 🕐❔ 🏗 👆 `FastAPI` 📱:
```Python hl_lines="9"
{!../../../docs_src/extending_openapi/tutorial002.py!}
```
### 🔌 🛃 🩺
🔜 👆 💪 ✍ *➡ 🛠️* 🛃 🩺.
👆 💪 🏤-⚙️ FastAPI 🔗 🔢 ✍ 🕸 📃 🩺, &amp; 🚶‍♀️ 👫 💪 ❌:
* `openapi_url`: 📛 🌐❔ 🕸 📃 🩺 💪 🤚 🗄 🔗 👆 🛠️. 👆 💪 ⚙️ 📥 🔢 `app.openapi_url`.
* `title`: 📛 👆 🛠️.
* `oauth2_redirect_url`: 👆 💪 ⚙️ `app.swagger_ui_oauth2_redirect_url` 📥 ⚙️ 🔢.
* `swagger_js_url`: 📛 🌐❔ 🕸 👆 🦁 🎚 🩺 💪 🤚 **🕸** 📁. 👉 1️⃣ 👈 👆 👍 📱 🔜 🍦.
* `swagger_css_url`: 📛 🌐❔ 🕸 👆 🦁 🎚 🩺 💪 🤚 **🎚** 📁. 👉 1️⃣ 👈 👆 👍 📱 🔜 🍦.
&amp; ➡ 📄...
```Python hl_lines="2-6 14-22 25-27 30-36"
{!../../../docs_src/extending_openapi/tutorial002.py!}
```
!!! tip
*➡ 🛠️* `swagger_ui_redirect` 👩‍🎓 🕐❔ 👆 ⚙️ Oauth2️⃣.
🚥 👆 🛠️ 👆 🛠️ ⏮️ Oauth2️⃣ 🐕‍🦺, 👆 🔜 💪 🔓 &amp; 👟 🔙 🛠️ 🩺 ⏮️ 📎 🎓. &amp; 🔗 ⏮️ ⚫️ ⚙️ 🎰 Oauth2️⃣ 🤝.
🦁 🎚 🔜 🍵 ⚫️ ⛅ 🎑 👆, ✋️ ⚫️ 💪 👉 "❎" 👩‍🎓.
### ✍ *➡ 🛠️* 💯 ⚫️
🔜, 💪 💯 👈 🌐 👷, ✍ *➡ 🛠️*:
```Python hl_lines="39-41"
{!../../../docs_src/extending_openapi/tutorial002.py!}
```
### 💯 ⚫️
🔜, 👆 🔜 💪 🔌 👆 📻, 🚶 👆 🩺 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>, &amp; 🔃 📃.
&amp; 🍵 🕸, 👆 🔜 💪 👀 🩺 👆 🛠️ &amp; 🔗 ⏮️ ⚫️.
## 🛠️ 🦁 🎚
👆 💪 🔗 ➕ <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration" class="external-link" target="_blank">🦁 🎚 🔢</a>.
🔗 👫, 🚶‍♀️ `swagger_ui_parameters` ❌ 🕐❔ 🏗 `FastAPI()` 📱 🎚 ⚖️ `get_swagger_ui_html()` 🔢.
`swagger_ui_parameters` 📨 📖 ⏮️ 📳 🚶‍♀️ 🦁 🎚 🔗.
FastAPI 🗜 📳 **🎻** ⚒ 👫 🔗 ⏮️ 🕸, 👈 ⚫️❔ 🦁 🎚 💪.
### ❎ ❕ 🎦
🖼, 👆 💪 ❎ ❕ 🎦 🦁 🎚.
🍵 🔀 ⚒, ❕ 🎦 🛠️ 🔢:
<img src="/img/tutorial/extending-openapi/image02.png">
✋️ 👆 💪 ❎ ⚫️ ⚒ `syntaxHighlight` `False`:
```Python hl_lines="3"
{!../../../docs_src/extending_openapi/tutorial003.py!}
```
...&amp; ⤴️ 🦁 🎚 🏆 🚫 🎦 ❕ 🎦 🚫🔜:
<img src="/img/tutorial/extending-openapi/image03.png">
### 🔀 🎢
🎏 🌌 👆 💪 ⚒ ❕ 🎦 🎢 ⏮️ 🔑 `"syntaxHighlight.theme"` (👀 👈 ⚫️ ✔️ ❣ 🖕):
```Python hl_lines="3"
{!../../../docs_src/extending_openapi/tutorial004.py!}
```
👈 📳 🔜 🔀 ❕ 🎦 🎨 🎢:
<img src="/img/tutorial/extending-openapi/image04.png">
### 🔀 🔢 🦁 🎚 🔢
FastAPI 🔌 🔢 📳 🔢 ☑ 🌅 ⚙️ 💼.
⚫️ 🔌 👫 🔢 📳:
```Python
{!../../../fastapi/openapi/docs.py[ln:7-13]!}
```
👆 💪 🔐 🙆 👫 ⚒ 🎏 💲 ❌ `swagger_ui_parameters`.
🖼, ❎ `deepLinking` 👆 💪 🚶‍♀️ 👉 ⚒ `swagger_ui_parameters`:
```Python hl_lines="3"
{!../../../docs_src/extending_openapi/tutorial005.py!}
```
### 🎏 🦁 🎚 🔢
👀 🌐 🎏 💪 📳 👆 💪 ⚙️, ✍ 🛂 <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration" class="external-link" target="_blank">🩺 🦁 🎚 🔢</a>.
### 🕸-🕴 ⚒
🦁 🎚 ✔ 🎏 📳 **🕸-🕴** 🎚 (🖼, 🕸 🔢).
FastAPI 🔌 👫 🕸-🕴 `presets` ⚒:
```JavaScript
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
]
```
👫 **🕸** 🎚, 🚫 🎻, 👆 💪 🚫 🚶‍♀️ 👫 ⚪️➡️ 🐍 📟 🔗.
🚥 👆 💪 ⚙️ 🕸-🕴 📳 💖 📚, 👆 💪 ⚙️ 1️⃣ 👩‍🔬 🔛. 🔐 🌐 🦁 🎚 *➡ 🛠️* &amp; ❎ ✍ 🙆 🕸 👆 💪.

267
docs/em/docs/advanced/generate-clients.md

@ -0,0 +1,267 @@
# 🏗 👩‍💻
**FastAPI** ⚓️ 🔛 🗄 🔧, 👆 🤚 🏧 🔗 ⏮️ 📚 🧰, 🔌 🏧 🛠️ 🩺 (🚚 🦁 🎚).
1️⃣ 🎯 📈 👈 🚫 🎯 ⭐ 👈 👆 💪 **🏗 👩‍💻** (🕣 🤙 <abbr title="Software Development Kits">**📱**</abbr> ) 👆 🛠️, 📚 🎏 **🛠️ 🇪🇸**.
## 🗄 👩‍💻 🚂
📤 📚 🧰 🏗 👩‍💻 ⚪️➡️ **🗄**.
⚠ 🧰 <a href="https://openapi-generator.tech/" class="external-link" target="_blank">🗄 🚂</a>.
🚥 👆 🏗 **🕸**, 📶 😌 🎛 <a href="https://github.com/ferdikoomen/openapi-typescript-codegen" class="external-link" target="_blank">🗄-📕-🇦🇪</a>.
## 🏗 📕 🕸 👩‍💻
➡️ ▶️ ⏮️ 🙅 FastAPI 🈸:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9-11 14-15 18 19 23"
{!> ../../../docs_src/generate_clients/tutorial001.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="7-9 12-13 16-17 21"
{!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
```
👀 👈 *➡ 🛠️* 🔬 🏷 👫 ⚙️ 📨 🚀 &amp; 📨 🚀, ⚙️ 🏷 `Item` &amp; `ResponseMessage`.
### 🛠️ 🩺
🚥 👆 🚶 🛠️ 🩺, 👆 🔜 👀 👈 ⚫️ ✔️ **🔗** 📊 📨 📨 &amp; 📨 📨:
<img src="/img/tutorial/generate-clients/image01.png">
👆 💪 👀 👈 🔗 ↩️ 👫 📣 ⏮️ 🏷 📱.
👈 ℹ 💪 📱 **🗄 🔗**, &amp; ⤴️ 🎦 🛠️ 🩺 (🦁 🎚).
&amp; 👈 🎏 ℹ ⚪️➡️ 🏷 👈 🔌 🗄 ⚫️❔ 💪 ⚙️ **🏗 👩‍💻 📟**.
### 🏗 📕 👩‍💻
🔜 👈 👥 ✔️ 📱 ⏮️ 🏷, 👥 💪 🏗 👩‍💻 📟 🕸.
#### ❎ `openapi-typescript-codegen`
👆 💪 ❎ `openapi-typescript-codegen` 👆 🕸 📟 ⏮️:
<div class="termy">
```console
$ npm install openapi-typescript-codegen --save-dev
---> 100%
```
</div>
#### 🏗 👩‍💻 📟
🏗 👩‍💻 📟 👆 💪 ⚙️ 📋 ⏸ 🈸 `openapi` 👈 🔜 🔜 ❎.
↩️ ⚫️ ❎ 🇧🇿 🏗, 👆 🎲 🚫🔜 💪 🤙 👈 📋 🔗, ✋️ 👆 🔜 🚮 ⚫️ 🔛 👆 `package.json` 📁.
⚫️ 💪 👀 💖 👉:
```JSON hl_lines="7"
{
"name": "frontend-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"generate-client": "openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
"openapi-typescript-codegen": "^0.20.1",
"typescript": "^4.6.2"
}
}
```
⏮️ ✔️ 👈 ☕ `generate-client` ✍ 📤, 👆 💪 🏃 ⚫️ ⏮️:
<div class="termy">
```console
$ npm run generate-client
[email protected] generate-client /home/user/code/frontend-app
> openapi --input http://localhost:8000/openapi.json --output ./src/client --client axios
```
</div>
👈 📋 🔜 🏗 📟 `./src/client` &amp; 🔜 ⚙️ `axios` (🕸 🇺🇸🔍 🗃) 🔘.
### 🔄 👅 👩‍💻 📟
🔜 👆 💪 🗄 &amp; ⚙️ 👩‍💻 📟, ⚫️ 💪 👀 💖 👉, 👀 👈 👆 🤚 ✍ 👩‍🔬:
<img src="/img/tutorial/generate-clients/image02.png">
👆 🔜 🤚 ✍ 🚀 📨:
<img src="/img/tutorial/generate-clients/image03.png">
!!! tip
👀 ✍ `name` &amp; `price`, 👈 🔬 FastAPI 🈸, `Item` 🏷.
👆 🔜 ✔️ ⏸ ❌ 📊 👈 👆 📨:
<img src="/img/tutorial/generate-clients/image04.png">
📨 🎚 🔜 ✔️ ✍:
<img src="/img/tutorial/generate-clients/image05.png">
## FastAPI 📱 ⏮️ 🔖
📚 💼 👆 FastAPI 📱 🔜 🦏, &amp; 👆 🔜 🎲 ⚙️ 🔖 🎏 🎏 👪 *➡ 🛠️*.
🖼, 👆 💪 ✔️ 📄 **🏬** &amp; ➕1️⃣ 📄 **👩‍💻**, &amp; 👫 💪 👽 🔖:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="23 28 36"
{!> ../../../docs_src/generate_clients/tutorial002.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="21 26 34"
{!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
```
### 🏗 📕 👩‍💻 ⏮️ 🔖
🚥 👆 🏗 👩‍💻 FastAPI 📱 ⚙️ 🔖, ⚫️ 🔜 🛎 🎏 👩‍💻 📟 ⚓️ 🔛 🔖.
👉 🌌 👆 🔜 💪 ✔️ 👜 ✔ &amp; 👪 ☑ 👩‍💻 📟:
<img src="/img/tutorial/generate-clients/image06.png">
👉 💼 👆 ✔️:
* `ItemsService`
* `UsersService`
### 👩‍💻 👩‍🔬 📛
▶️️ 🔜 🏗 👩‍🔬 📛 💖 `createItemItemsPost` 🚫 👀 📶 🧹:
```TypeScript
ItemsService.createItemItemsPost({name: "Plumbus", price: 5})
```
...👈 ↩️ 👩‍💻 🚂 ⚙️ 🗄 🔗 **🛠️ 🆔** 🔠 *➡ 🛠️*.
🗄 🚚 👈 🔠 🛠️ 🆔 😍 🤭 🌐 *➡ 🛠️*, FastAPI ⚙️ **🔢 📛**, **➡**, &amp; **🇺🇸🔍 👩‍🔬/🛠️** 🏗 👈 🛠️ 🆔, ↩️ 👈 🌌 ⚫️ 💪 ⚒ 💭 👈 🛠️ 🆔 😍.
✋️ 👤 🔜 🎦 👆 ❔ 📉 👈 ⏭. 👶
## 🛃 🛠️ 🆔 &amp; 👍 👩‍🔬 📛
👆 💪 **🔀** 🌌 👫 🛠️ 🆔 **🏗** ⚒ 👫 🙅 &amp; ✔️ **🙅 👩‍🔬 📛** 👩‍💻.
👉 💼 👆 🔜 ✔️ 🚚 👈 🔠 🛠️ 🆔 **😍** 🎏 🌌.
🖼, 👆 💪 ⚒ 💭 👈 🔠 *➡ 🛠️* ✔️ 🔖, &amp; ⤴️ 🏗 🛠️ 🆔 ⚓️ 🔛 **🔖** &amp; *➡ 🛠️* **📛** (🔢 📛).
### 🛃 🏗 😍 🆔 🔢
FastAPI ⚙️ **😍 🆔** 🔠 *➡ 🛠️*, ⚫️ ⚙️ **🛠️ 🆔** &amp; 📛 🙆 💪 🛃 🏷, 📨 ⚖️ 📨.
👆 💪 🛃 👈 🔢. ⚫️ ✊ `APIRoute` &amp; 🔢 🎻.
🖼, 📥 ⚫️ ⚙️ 🥇 🔖 (👆 🔜 🎲 ✔️ 🕴 1️⃣ 🔖) &amp; *➡ 🛠️* 📛 (🔢 📛).
👆 💪 ⤴️ 🚶‍♀️ 👈 🛃 🔢 **FastAPI** `generate_unique_id_function` 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="8-9 12"
{!> ../../../docs_src/generate_clients/tutorial003.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="6-7 10"
{!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
```
### 🏗 📕 👩‍💻 ⏮️ 🛃 🛠️ 🆔
🔜 🚥 👆 🏗 👩‍💻 🔄, 👆 🔜 👀 👈 ⚫️ ✔️ 📉 👩‍🔬 📛:
<img src="/img/tutorial/generate-clients/image07.png">
👆 👀, 👩‍🔬 📛 🔜 ✔️ 🔖 &amp; ⤴️ 🔢 📛, 🔜 👫 🚫 🔌 ℹ ⚪️➡️ 📛 ➡ &amp; 🇺🇸🔍 🛠️.
### 🗜 🗄 🔧 👩‍💻 🚂
🏗 📟 ✔️ **❎ ℹ**.
👥 ⏪ 💭 👈 👉 👩‍🔬 🔗 **🏬** ↩️ 👈 🔤 `ItemsService` (✊ ⚪️➡️ 🔖), ✋️ 👥 ✔️ 📛 🔡 👩‍🔬 📛 💁‍♂️. 👶
👥 🔜 🎲 💚 🚧 ⚫️ 🗄 🏢, 👈 🔜 🚚 👈 🛠️ 🆔 **😍**.
✋️ 🏗 👩‍💻 👥 💪 **🔀** 🗄 🛠️ 🆔 ▶️️ ⏭ 🏭 👩‍💻, ⚒ 👈 👩‍🔬 📛 👌 &amp; **🧹**.
👥 💪 ⏬ 🗄 🎻 📁 `openapi.json` &amp; ⤴️ 👥 💪 **❎ 👈 🔡 🔖** ⏮️ ✍ 💖 👉:
```Python
{!../../../docs_src/generate_clients/tutorial004.py!}
```
⏮️ 👈, 🛠️ 🆔 🔜 📁 ⚪️➡️ 👜 💖 `items-get_items` `get_items`, 👈 🌌 👩‍💻 🚂 💪 🏗 🙅 👩‍🔬 📛.
### 🏗 📕 👩‍💻 ⏮️ 🗜 🗄
🔜 🔚 🏁 📁 `openapi.json`, 👆 🔜 🔀 `package.json` ⚙️ 👈 🇧🇿 📁, 🖼:
```JSON hl_lines="7"
{
"name": "frontend-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"generate-client": "openapi --input ./openapi.json --output ./src/client --client axios"
},
"author": "",
"license": "",
"devDependencies": {
"openapi-typescript-codegen": "^0.20.1",
"typescript": "^4.6.2"
}
}
```
⏮️ 🏭 🆕 👩‍💻, 👆 🔜 🔜 ✔️ **🧹 👩‍🔬 📛**, ⏮️ 🌐 **✍**, **⏸ ❌**, ♒️:
<img src="/img/tutorial/generate-clients/image08.png">
## 💰
🕐❔ ⚙️ 🔁 🏗 👩‍💻 👆 🔜 **✍** :
* 👩‍🔬.
* 📨 🚀 💪, 🔢 🔢, ♒️.
* 📨 🚀.
👆 🔜 ✔️ **⏸ ❌** 🌐.
&amp; 🕐❔ 👆 ℹ 👩‍💻 📟, &amp; **♻** 🕸, ⚫️ 🔜 ✔️ 🙆 🆕 *➡ 🛠️* 💪 👩‍🔬, 🗝 🕐 ❎, &amp; 🙆 🎏 🔀 🔜 🎨 🔛 🏗 📟. 👶
👉 ⛓ 👈 🚥 🕳 🔀 ⚫️ 🔜 **🎨** 🔛 👩‍💻 📟 🔁. &amp; 🚥 👆 **🏗** 👩‍💻 ⚫️ 🔜 ❌ 👅 🚥 👆 ✔️ 🙆 **🔖** 📊 ⚙️.
, 👆 🔜 **🔍 📚 ❌** 📶 ⏪ 🛠️ 🛵 ↩️ ✔️ ⌛ ❌ 🎦 🆙 👆 🏁 👩‍💻 🏭 &amp; ⤴️ 🔄 ℹ 🌐❔ ⚠. 👶

56
docs/em/docs/advanced/graphql.md

@ -0,0 +1,56 @@
# 🕹
**FastAPI** ⚓️ 🔛 **🔫** 🐩, ⚫️ 📶 ⏩ 🛠️ 🙆 **🕹** 🗃 🔗 ⏮️ 🔫.
👆 💪 🌀 😐 FastAPI *➡ 🛠️* ⏮️ 🕹 🔛 🎏 🈸.
!!! tip
**🕹** ❎ 📶 🎯 ⚙️ 💼.
⚫️ ✔️ **📈** &amp; **⚠** 🕐❔ 🔬 ⚠ **🕸 🔗**.
⚒ 💭 👆 🔬 🚥 **💰** 👆 ⚙️ 💼 ⚖ **👐**. 👶
## 🕹 🗃
📥 **🕹** 🗃 👈 ✔️ **🔫** 🐕‍🦺. 👆 💪 ⚙️ 👫 ⏮️ **FastAPI**:
* <a href="https://strawberry.rocks/" class="external-link" target="_blank">🍓</a> 👶
* ⏮️ <a href="https://strawberry.rocks/docs/integrations/fastapi" class="external-link" target="_blank">🩺 FastAPI</a>
* <a href="https://ariadnegraphql.org/" class="external-link" target="_blank">👸</a>
* ⏮️ <a href="https://ariadnegraphql.org/docs/starlette-integration" class="external-link" target="_blank">🩺 💃</a> (👈 ✔ FastAPI)
* <a href="https://tartiflette.io/" class="external-link" target="_blank">🍟</a>
* ⏮️ <a href="https://tartiflette.github.io/tartiflette-asgi/" class="external-link" target="_blank">🍟 🔫</a> 🚚 🔫 🛠️
* <a href="https://graphene-python.org/" class="external-link" target="_blank"></a>
* ⏮️ <a href="https://github.com/ciscorn/starlette-graphene3" class="external-link" target="_blank">💃-Graphene3️⃣</a>
## 🕹 ⏮️ 🍓
🚥 👆 💪 ⚖️ 💚 👷 ⏮️ **🕹**, <a href="https://strawberry.rocks/" class="external-link" target="_blank">**🍓**</a> **👍** 🗃 ⚫️ ✔️ 🔧 🔐 **FastAPI** 🔧, ⚫️ 🌐 ⚓️ 🔛 **🆎 ✍**.
⚓️ 🔛 👆 ⚙️ 💼, 👆 5️⃣📆 💖 ⚙️ 🎏 🗃, ✋️ 🚥 👆 💭 👤, 👤 🔜 🎲 🤔 👆 🔄 **🍓**.
📥 🤪 🎮 ❔ 👆 💪 🛠️ 🍓 ⏮️ FastAPI:
```Python hl_lines="3 22 25-26"
{!../../../docs_src/graphql/tutorial001.py!}
```
👆 💪 💡 🌅 🔃 🍓 <a href="https://strawberry.rocks/" class="external-link" target="_blank">🍓 🧾</a>.
&amp; 🩺 🔃 <a href="https://strawberry.rocks/docs/integrations/fastapi" class="external-link" target="_blank">🍓 ⏮️ FastAPI</a>.
## 🗝 `GraphQLApp` ⚪️➡️ 💃
⏮️ ⏬ 💃 🔌 `GraphQLApp` 🎓 🛠️ ⏮️ <a href="https://graphene-python.org/" class="external-link" target="_blank"></a>.
⚫️ 😢 ⚪️➡️ 💃, ✋️ 🚥 👆 ✔️ 📟 👈 ⚙️ ⚫️, 👆 💪 💪 **↔** <a href="https://github.com/ciscorn/starlette-graphene3" class="external-link" target="_blank">💃-Graphene3️⃣</a>, 👈 📔 🎏 ⚙️ 💼 &amp; ✔️ **🌖 🌓 🔢**.
!!! tip
🚥 👆 💪 🕹, 👤 🔜 👍 👆 ✅ 👅 <a href="https://strawberry.rocks/" class="external-link" target="_blank">🍓</a>, ⚫️ ⚓️ 🔛 🆎 ✍ ↩️ 🛃 🎓 &amp; 🆎.
## 💡 🌅
👆 💪 💡 🌅 🔃 **🕹** <a href="https://graphql.org/" class="external-link" target="_blank">🛂 🕹 🧾</a>.
👆 💪 ✍ 🌅 🔃 🔠 👈 🗃 🔬 🔛 👫 🔗.

24
docs/em/docs/advanced/index.md

@ -0,0 +1,24 @@
# 🏧 👩‍💻 🦮
## 🌖 ⚒
👑 [🔰 - 👩‍💻 🦮](../tutorial/){.internal-link target=_blank} 🔜 🥃 🤝 👆 🎫 🔘 🌐 👑 ⚒ **FastAPI**.
⏭ 📄 👆 🔜 👀 🎏 🎛, 📳, &amp; 🌖 ⚒.
!!! tip
⏭ 📄 **🚫 🎯 "🏧"**.
&amp; ⚫️ 💪 👈 👆 ⚙️ 💼, ⚗ 1️⃣ 👫.
## ✍ 🔰 🥇
👆 💪 ⚙️ 🏆 ⚒ **FastAPI** ⏮️ 💡 ⚪️➡️ 👑 [🔰 - 👩‍💻 🦮](../tutorial/){.internal-link target=_blank}.
&amp; ⏭ 📄 🤔 👆 ⏪ ✍ ⚫️, &amp; 🤔 👈 👆 💭 👈 👑 💭.
## 🏎.🅾 ↗️
🚥 👆 🔜 💖 ✊ 🏧-🔰 ↗️ 🔗 👉 📄 🩺, 👆 💪 💚 ✅: <a href="https://testdriven.io/courses/tdd-fastapi/" class="external-link" target="_blank">💯-💾 🛠️ ⏮️ FastAPI &amp;</a> **🏎.🅾**.
👫 ⏳ 🩸 1️⃣0️⃣ 💯 🌐 💰 🛠️ **FastAPI**. 👶 👶

99
docs/em/docs/advanced/middleware.md

@ -0,0 +1,99 @@
# 🏧 🛠️
👑 🔰 👆 ✍ ❔ 🚮 [🛃 🛠️](../tutorial/middleware.md){.internal-link target=_blank} 👆 🈸.
&amp; ⤴️ 👆 ✍ ❔ 🍵 [⚜ ⏮️ `CORSMiddleware`](../tutorial/cors.md){.internal-link target=_blank}.
👉 📄 👥 🔜 👀 ❔ ⚙️ 🎏 🛠️.
## ❎ 🔫 🛠️
**FastAPI** ⚓️ 🔛 💃 &amp; 🛠️ <abbr title="Asynchronous Server Gateway Interface">🔫</abbr> 🔧, 👆 💪 ⚙️ 🙆 🔫 🛠️.
🛠️ 🚫 ✔️ ⚒ FastAPI ⚖️ 💃 👷, 📏 ⚫️ ⏩ 🔫 🔌.
🏢, 🔫 🛠️ 🎓 👈 ⌛ 📨 🔫 📱 🥇 ❌.
, 🧾 🥉-🥳 🔫 🛠️ 👫 🔜 🎲 💬 👆 🕳 💖:
```Python
from unicorn import UnicornMiddleware
app = SomeASGIApp()
new_app = UnicornMiddleware(app, some_config="rainbow")
```
✋️ FastAPI (🤙 💃) 🚚 🙅 🌌 ⚫️ 👈 ⚒ 💭 👈 🔗 🛠️ 🍵 💽 ❌ &amp; 🛃 ⚠ 🐕‍🦺 👷 ☑.
👈, 👆 ⚙️ `app.add_middleware()` (🖼 ⚜).
```Python
from fastapi import FastAPI
from unicorn import UnicornMiddleware
app = FastAPI()
app.add_middleware(UnicornMiddleware, some_config="rainbow")
```
`app.add_middleware()` 📨 🛠️ 🎓 🥇 ❌ &amp; 🙆 🌖 ❌ 🚶‍♀️ 🛠️.
## 🛠️ 🛠️
**FastAPI** 🔌 📚 🛠️ ⚠ ⚙️ 💼, 👥 🔜 👀 ⏭ ❔ ⚙️ 👫.
!!! note "📡 ℹ"
⏭ 🖼, 👆 💪 ⚙️ `from starlette.middleware.something import SomethingMiddleware`.
**FastAPI** 🚚 📚 🛠️ `fastapi.middleware` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 🛠️ 👟 🔗 ⚪️➡️ 💃.
## `HTTPSRedirectMiddleware`
🛠️ 👈 🌐 📨 📨 🔜 👯‍♂️ `https` ⚖️ `wss`.
🙆 📨 📨 `http` ⚖️ `ws` 🔜 ❎ 🔐 ⚖ ↩️.
```Python hl_lines="2 6"
{!../../../docs_src/advanced_middleware/tutorial001.py!}
```
## `TrustedHostMiddleware`
🛠️ 👈 🌐 📨 📨 ✔️ ☑ ⚒ `Host` 🎚, ✔ 💂‍♂ 🛡 🇺🇸🔍 🦠 🎚 👊.
```Python hl_lines="2 6-8"
{!../../../docs_src/advanced_middleware/tutorial002.py!}
```
📄 ❌ 🐕‍🦺:
* `allowed_hosts` - 📇 🆔 📛 👈 🔜 ✔ 📛. 🃏 🆔 ✅ `*.example.com` 🐕‍🦺 🎀 📁. ✔ 🙆 📛 👯‍♂️ ⚙️ `allowed_hosts=["*"]` ⚖️ 🚫 🛠️.
🚥 📨 📨 🔨 🚫 ✔ ☑ ⤴️ `400` 📨 🔜 📨.
## `GZipMiddleware`
🍵 🗜 📨 🙆 📨 👈 🔌 `"gzip"` `Accept-Encoding` 🎚.
🛠️ 🔜 🍵 👯‍♂️ 🐩 &amp; 🎥 📨.
```Python hl_lines="2 6"
{!../../../docs_src/advanced_middleware/tutorial003.py!}
```
📄 ❌ 🐕‍🦺:
* `minimum_size` - 🚫 🗜 📨 👈 🤪 🌘 👉 💯 📐 🔢. 🔢 `500`.
## 🎏 🛠️
📤 📚 🎏 🔫 🛠️.
🖼:
* <a href="https://docs.sentry.io/platforms/python/asgi/" class="external-link" target="_blank">🔫</a>
* <a href="https://github.com/encode/uvicorn/blob/master/uvicorn/middleware/proxy_headers.py" class="external-link" target="_blank">Uvicorn `ProxyHeadersMiddleware`</a>
* <a href="https://github.com/florimondmanca/msgpack-asgi" class="external-link" target="_blank">🇸🇲</a>
👀 🎏 💪 🛠️ ✅ <a href="https://www.starlette.io/middleware/" class="external-link" target="_blank">💃 🛠️ 🩺</a> &amp; <a href="https://github.com/florimondmanca/awesome-asgi" class="external-link" target="_blank">🔫 👌 📇</a>.

156
docs/em/docs/advanced/nosql-databases.md

@ -0,0 +1,156 @@
# ☁ (📎 / 🦏 💽) 💽
**FastAPI** 💪 🛠️ ⏮️ 🙆 <abbr title="Distributed database (Big Data), also 'Not Only SQL'"></abbr>.
📥 👥 🔜 👀 🖼 ⚙️ **<a href="https://www.couchbase.com/" class="external-link" target="_blank">🗄</a>**, <abbr title="Document here refers to a JSON object (a dict), with keys and values, and those values can also be other JSON objects, arrays (lists), numbers, strings, booleans, etc.">📄</abbr> 🧢 ☁ 💽.
👆 💪 🛠️ ⚫️ 🙆 🎏 ☁ 💽 💖:
* **✳**
* **👸**
* **✳**
* **🇸🇲**
* **✳**, ♒️.
!!! tip
📤 🛂 🏗 🚂 ⏮️ **FastAPI** &amp; **🗄**, 🌐 ⚓️ 🔛 **☁**, 🔌 🕸 &amp; 🌖 🧰: <a href="https://github.com/tiangolo/full-stack-fastapi-couchbase" class="external-link" target="_blank">https://github.com/tiangolo/full-stack-fastapi-couchbase</a>
## 🗄 🗄 🦲
🔜, 🚫 💸 🙋 🎂, 🕴 🗄:
```Python hl_lines="3-5"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
## 🔬 📉 ⚙️ "📄 🆎"
👥 🔜 ⚙️ ⚫️ ⏪ 🔧 🏑 `type` 👆 📄.
👉 🚫 ✔ 🗄, ✋️ 👍 💡 👈 🔜 ℹ 👆 ⏮️.
```Python hl_lines="9"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
## 🚮 🔢 🤚 `Bucket`
**🗄**, 🥡 ⚒ 📄, 👈 💪 🎏 🆎.
👫 🛎 🌐 🔗 🎏 🈸.
🔑 🔗 💽 🌏 🔜 "💽" (🎯 💽, 🚫 💽 💽).
🔑 **✳** 🔜 "🗃".
📟, `Bucket` 🎨 👑 🇨🇻 📻 ⏮️ 💽.
👉 🚙 🔢 🔜:
* 🔗 **🗄** 🌑 (👈 💪 👁 🎰).
* ⚒ 🔢 ⏲.
* 🔓 🌑.
* 🤚 `Bucket` 👐.
* ⚒ 🔢 ⏲.
* 📨 ⚫️.
```Python hl_lines="12-21"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
## ✍ Pydantic 🏷
**🗄** "📄" 🤙 "🎻 🎚", 👥 💪 🏷 👫 ⏮️ Pydantic.
### `User` 🏷
🥇, ➡️ ✍ `User` 🏷:
```Python hl_lines="24-28"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
👥 🔜 ⚙️ 👉 🏷 👆 *➡ 🛠️ 🔢*,, 👥 🚫 🔌 ⚫️ `hashed_password`.
### `UserInDB` 🏷
🔜, ➡️ ✍ `UserInDB` 🏷.
👉 🔜 ✔️ 💽 👈 🤙 🏪 💽.
👥 🚫 ✍ ⚫️ 🏿 Pydantic `BaseModel` ✋️ 🏿 👆 👍 `User`, ↩️ ⚫️ 🔜 ✔️ 🌐 🔢 `User` ➕ 👩‍❤‍👨 🌅:
```Python hl_lines="31-33"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
!!! note
👀 👈 👥 ✔️ `hashed_password` &amp; `type` 🏑 👈 🔜 🏪 💽.
✋️ ⚫️ 🚫 🍕 🏢 `User` 🏷 (1️⃣ 👥 🔜 📨 *➡ 🛠️*).
## 🤚 👩‍💻
🔜 ✍ 🔢 👈 🔜:
* ✊ 🆔.
* 🏗 📄 🆔 ⚪️➡️ ⚫️.
* 🤚 📄 ⏮️ 👈 🆔.
* 🚮 🎚 📄 `UserInDB` 🏷.
🏗 🔢 👈 🕴 💡 🤚 👆 👩‍💻 ⚪️➡️ `username` (⚖️ 🙆 🎏 🔢) 🔬 👆 *➡ 🛠️ 🔢*, 👆 💪 🌖 💪 🏤-⚙️ ⚫️ 💗 🍕 &amp; 🚮 <abbr title="Automated test, written in code, that checks if another piece of code is working correctly.">⚒ 💯</abbr> ⚫️:
```Python hl_lines="36-42"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
### Ⓜ-🎻
🚥 👆 🚫 😰 ⏮️ `f"userprofile::{username}"`, ⚫️ 🐍 "<a href="https://docs.python.org/3/glossary.html#term-f-string" class="external-link" target="_blank">Ⓜ-🎻</a>".
🙆 🔢 👈 🚮 🔘 `{}` Ⓜ-🎻 🔜 ↔ / 💉 🎻.
### `dict` 🏗
🚥 👆 🚫 😰 ⏮️ `UserInDB(**result.value)`, <a href="https://docs.python.org/3/glossary.html#term-argument" class="external-link" target="_blank">⚫️ ⚙️ `dict` "🏗"</a>.
⚫️ 🔜 ✊ `dict` `result.value`, &amp; ✊ 🔠 🚮 🔑 &amp; 💲 &amp; 🚶‍♀️ 👫 🔑-💲 `UserInDB` 🇨🇻 ❌.
, 🚥 `dict` 🔌:
```Python
{
"username": "johndoe",
"hashed_password": "some_hash",
}
```
⚫️ 🔜 🚶‍♀️ `UserInDB` :
```Python
UserInDB(username="johndoe", hashed_password="some_hash")
```
## ✍ 👆 **FastAPI** 📟
### ✍ `FastAPI` 📱
```Python hl_lines="46"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
### ✍ *➡ 🛠️ 🔢*
👆 📟 🤙 🗄 &amp; 👥 🚫 ⚙️ <a href="https://docs.couchbase.com/python-sdk/2.5/async-programming.html#asyncio-python-3-5" class="external-link" target="_blank">🥼 🐍 <code>await</code> 🐕‍🦺</a>, 👥 🔜 📣 👆 🔢 ⏮️ 😐 `def` ↩️ `async def`.
, 🗄 👍 🚫 ⚙️ 👁 `Bucket` 🎚 💗 "<abbr title="A sequence of code being executed by the program, while at the same time, or at intervals, there can be others being executed too.">🧵</abbr>Ⓜ",, 👥 💪 🤚 🥡 🔗 &amp; 🚶‍♀️ ⚫️ 👆 🚙 🔢:
```Python hl_lines="49-53"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
## 🌃
👆 💪 🛠️ 🙆 🥉 🥳 ☁ 💽, ⚙️ 👫 🐩 📦.
🎏 ✔ 🙆 🎏 🔢 🧰, ⚙️ ⚖️ 🛠️.

179
docs/em/docs/advanced/openapi-callbacks.md

@ -0,0 +1,179 @@
# 🗄 ⏲
👆 💪 ✍ 🛠️ ⏮️ *➡ 🛠️* 👈 💪 ⏲ 📨 *🔢 🛠️* ✍ 👱 🙆 (🎲 🎏 👩‍💻 👈 🔜 *⚙️* 👆 🛠️).
🛠️ 👈 🔨 🕐❔ 👆 🛠️ 📱 🤙 *🔢 🛠️* 📛 "⏲". ↩️ 🖥 👈 🔢 👩‍💻 ✍ 📨 📨 👆 🛠️ &amp; ⤴️ 👆 🛠️ *🤙 🔙*, 📨 📨 *🔢 🛠️* (👈 🎲 ✍ 🎏 👩‍💻).
👉 💼, 👆 💪 💚 📄 ❔ 👈 🔢 🛠️ *🔜* 👀 💖. ⚫️❔ *➡ 🛠️* ⚫️ 🔜 ✔️, ⚫️❔ 💪 ⚫️ 🔜 ⌛, ⚫️❔ 📨 ⚫️ 🔜 📨, ♒️.
## 📱 ⏮️ ⏲
➡️ 👀 🌐 👉 ⏮️ 🖼.
🌈 👆 🛠️ 📱 👈 ✔ 🏗 🧾.
👉 🧾 🔜 ✔️ `id`, `title` (📦), `customer`, &amp; `total`.
👩‍💻 👆 🛠️ (🔢 👩‍💻) 🔜 ✍ 🧾 👆 🛠️ ⏮️ 🏤 📨.
⤴️ 👆 🛠️ 🔜 (➡️ 🌈):
* 📨 🧾 🕴 🔢 👩‍💻.
* 📈 💸.
* 📨 📨 🔙 🛠️ 👩‍💻 (🔢 👩‍💻).
* 👉 🔜 🔨 📨 🏤 📨 (⚪️➡️ *👆 🛠️*) *🔢 🛠️* 🚚 👈 🔢 👩‍💻 (👉 "⏲").
## 😐 **FastAPI** 📱
➡️ 🥇 👀 ❔ 😐 🛠️ 📱 🔜 👀 💖 ⏭ ❎ ⏲.
⚫️ 🔜 ✔️ *➡ 🛠️* 👈 🔜 📨 `Invoice` 💪, &amp; 🔢 🔢 `callback_url` 👈 🔜 🔌 📛 ⏲.
👉 🍕 📶 😐, 🌅 📟 🎲 ⏪ 😰 👆:
```Python hl_lines="9-13 36-53"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
!!! tip
`callback_url` 🔢 🔢 ⚙️ Pydantic <a href="https://pydantic-docs.helpmanual.io/usage/types/#urls" class="external-link" target="_blank">📛</a> 🆎.
🕴 🆕 👜 `callbacks=messages_callback_router.routes`*➡ 🛠️ 👨‍🎨*. 👥 🔜 👀 ⚫️❔ 👈 ⏭.
## 🔬 ⏲
☑ ⏲ 📟 🔜 🪀 🙇 🔛 👆 👍 🛠️ 📱.
&amp; ⚫️ 🔜 🎲 🪀 📚 ⚪️➡️ 1️⃣ 📱 ⏭.
⚫️ 💪 1️⃣ ⚖️ 2️⃣ ⏸ 📟, 💖:
```Python
callback_url = "https://example.com/api/v1/invoices/events/"
httpx.post(callback_url, json={"description": "Invoice paid", "paid": True})
```
✋️ 🎲 🏆 ⚠ 🍕 ⏲ ⚒ 💭 👈 👆 🛠️ 👩‍💻 (🔢 👩‍💻) 🛠️ *🔢 🛠️* ☑, 🛄 💽 👈 *👆 🛠️* 🔜 📨 📨 💪 ⏲, ♒️.
, ⚫️❔ 👥 🔜 ⏭ 🚮 📟 📄 ❔ 👈 *🔢 🛠️* 🔜 👀 💖 📨 ⏲ ⚪️➡️ *👆 🛠️*.
👈 🧾 🔜 🎦 🆙 🦁 🎚 `/docs` 👆 🛠️, &amp; ⚫️ 🔜 ➡️ 🔢 👩‍💻 💭 ❔ 🏗 *🔢 🛠️*.
👉 🖼 🚫 🛠️ ⏲ ⚫️ (👈 💪 ⏸ 📟), 🕴 🧾 🍕.
!!! tip
☑ ⏲ 🇺🇸🔍 📨.
🕐❔ 🛠️ ⏲ 👆, 👆 💪 ⚙️ 🕳 💖 <a href="https://www.python-httpx.org" class="external-link" target="_blank">🇸🇲</a> ⚖️ <a href="https://requests.readthedocs.io/" class="external-link" target="_blank">📨</a>.
## ✍ ⏲ 🧾 📟
👉 📟 🏆 🚫 🛠️ 👆 📱, 👥 🕴 💪 ⚫️ *📄* ❔ 👈 *🔢 🛠️* 🔜 👀 💖.
✋️, 👆 ⏪ 💭 ❔ 💪 ✍ 🏧 🧾 🛠️ ⏮️ **FastAPI**.
👥 🔜 ⚙️ 👈 🎏 💡 📄 ❔ *🔢 🛠️* 🔜 👀 💖... 🏗 *➡ 🛠️(Ⓜ)* 👈 🔢 🛠️ 🔜 🛠️ (🕐 👆 🛠️ 🔜 🤙).
!!! tip
🕐❔ ✍ 📟 📄 ⏲, ⚫️ 💪 ⚠ 🌈 👈 👆 👈 *🔢 👩‍💻*. &amp; 👈 👆 ⏳ 🛠️ *🔢 🛠️*, 🚫 *👆 🛠️*.
🍕 🛠️ 👉 ☝ 🎑 ( *🔢 👩‍💻*) 💪 ℹ 👆 💭 💖 ⚫️ 🌅 ⭐ 🌐❔ 🚮 🔢, Pydantic 🏷 💪, 📨, ♒️. 👈 *🔢 🛠️*.
### ✍ ⏲ `APIRouter`
🥇 ✍ 🆕 `APIRouter` 👈 🔜 🔌 1️⃣ ⚖️ 🌅 ⏲.
```Python hl_lines="3 25"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
### ✍ ⏲ *➡ 🛠️*
✍ ⏲ *➡ 🛠️* ⚙️ 🎏 `APIRouter` 👆 ✍ 🔛.
⚫️ 🔜 👀 💖 😐 FastAPI *➡ 🛠️*:
* ⚫️ 🔜 🎲 ✔️ 📄 💪 ⚫️ 🔜 📨, ✅ `body: InvoiceEvent`.
* &amp; ⚫️ 💪 ✔️ 📄 📨 ⚫️ 🔜 📨, ✅ `response_model=InvoiceEventReceived`.
```Python hl_lines="16-18 21-22 28-32"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
📤 2️⃣ 👑 🔺 ⚪️➡️ 😐 *➡ 🛠️*:
* ⚫️ 🚫 💪 ✔️ 🙆 ☑ 📟, ↩️ 👆 📱 🔜 🙅 🤙 👉 📟. ⚫️ 🕴 ⚙️ 📄 *🔢 🛠️*. , 🔢 💪 ✔️ `pass`.
* *➡* 💪 🔌 <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#key-expression" class="external-link" target="_blank">🗄 3️⃣ 🧬</a> (👀 🌖 🔛) 🌐❔ ⚫️ 💪 ⚙️ 🔢 ⏮️ 🔢 &amp; 🍕 ⏮️ 📨 📨 *👆 🛠️*.
### ⏲ ➡ 🧬
*➡* 💪 ✔️ <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#key-expression" class="external-link" target="_blank">🗄 3️⃣ 🧬</a> 👈 💪 🔌 🍕 ⏮️ 📨 📨 *👆 🛠️*.
👉 💼, ⚫️ `str`:
```Python
"{$callback_url}/invoices/{$request.body.id}"
```
, 🚥 👆 🛠️ 👩‍💻 (🔢 👩‍💻) 📨 📨 *👆 🛠️* :
```
https://yourapi.com/invoices/?callback_url=https://www.external.org/events
```
⏮️ 🎻 💪:
```JSON
{
"id": "2expen51ve",
"customer": "Mr. Richie Rich",
"total": "9999"
}
```
⤴️ *👆 🛠️* 🔜 🛠️ 🧾, &amp; ☝ ⏪, 📨 ⏲ 📨 `callback_url` ( *🔢 🛠️*):
```
https://www.external.org/events/invoices/2expen51ve
```
⏮️ 🎻 💪 ⚗ 🕳 💖:
```JSON
{
"description": "Payment celebration",
"paid": true
}
```
&amp; ⚫️ 🔜 ⌛ 📨 ⚪️➡️ 👈 *🔢 🛠️* ⏮️ 🎻 💪 💖:
```JSON
{
"ok": true
}
```
!!! tip
👀 ❔ ⏲ 📛 ⚙️ 🔌 📛 📨 🔢 🔢 `callback_url` (`https://www.external.org/events`) &amp; 🧾 `id` ⚪️➡️ 🔘 🎻 💪 (`2expen51ve`).
### 🚮 ⏲ 📻
👉 ☝ 👆 ✔️ *⏲ ➡ 🛠️(Ⓜ)* 💪 (1️⃣(Ⓜ) 👈 *🔢 👩‍💻* 🔜 🛠️ *🔢 🛠️*) ⏲ 📻 👆 ✍ 🔛.
🔜 ⚙️ 🔢 `callbacks` *👆 🛠️ ➡ 🛠️ 👨‍🎨* 🚶‍♀️ 🔢 `.routes` (👈 🤙 `list` 🛣/*➡ 🛠️*) ⚪️➡️ 👈 ⏲ 📻:
```Python hl_lines="35"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
!!! tip
👀 👈 👆 🚫 🚶‍♀️ 📻 ⚫️ (`invoices_callback_router`) `callback=`, ✋️ 🔢 `.routes`, `invoices_callback_router.routes`.
### ✅ 🩺
🔜 👆 💪 ▶️ 👆 📱 ⏮️ Uvicorn &amp; 🚶 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
👆 🔜 👀 👆 🩺 ✅ "⏲" 📄 👆 *➡ 🛠️* 👈 🎦 ❔ *🔢 🛠️* 🔜 👀 💖:
<img src="/img/tutorial/openapi-callbacks/image01.png">

170
docs/em/docs/advanced/path-operation-advanced-configuration.md

@ -0,0 +1,170 @@
# ➡ 🛠️ 🏧 📳
## 🗄 {
!!! warning
🚥 👆 🚫 "🕴" 🗄, 👆 🎲 🚫 💪 👉.
👆 💪 ⚒ 🗄 `operationId` ⚙️ 👆 *➡ 🛠️* ⏮️ 🔢 `operation_id`.
👆 🔜 ✔️ ⚒ 💭 👈 ⚫️ 😍 🔠 🛠️.
```Python hl_lines="6"
{!../../../docs_src/path_operation_advanced_configuration/tutorial001.py!}
```
### ⚙️ *➡ 🛠️ 🔢* 📛 {
🚥 👆 💚 ⚙️ 👆 🔗' 🔢 📛 `operationId`Ⓜ, 👆 💪 🔁 🤭 🌐 👫 &amp; 🔐 🔠 *➡ 🛠️* `operation_id` ⚙️ 👫 `APIRoute.name`.
👆 🔜 ⚫️ ⏮️ ❎ 🌐 👆 *➡ 🛠️*.
```Python hl_lines="2 12-21 24"
{!../../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
```
!!! tip
🚥 👆 ❎ 🤙 `app.openapi()`, 👆 🔜 ℹ `operationId`Ⓜ ⏭ 👈.
!!! warning
🚥 👆 👉, 👆 ✔️ ⚒ 💭 🔠 1️⃣ 👆 *➡ 🛠️ 🔢* ✔️ 😍 📛.
🚥 👫 🎏 🕹 (🐍 📁).
## 🚫 ⚪️➡️ 🗄
🚫 *➡ 🛠️* ⚪️➡️ 🏗 🗄 🔗 (&amp; ➡️, ⚪️➡️ 🏧 🧾 ⚙️), ⚙️ 🔢 `include_in_schema` &amp; ⚒ ⚫️ `False`:
```Python hl_lines="6"
{!../../../docs_src/path_operation_advanced_configuration/tutorial003.py!}
```
## 🏧 📛 ⚪️➡️ #️
👆 💪 📉 ⏸ ⚙️ ⚪️➡️ #️*➡ 🛠️ 🔢* 🗄.
`\f` (😖 "📨 🍼" 🦹) 🤕 **FastAPI** 🔁 🔢 ⚙️ 🗄 👉 ☝.
⚫️ 🏆 🚫 🎦 🆙 🧾, ✋️ 🎏 🧰 (✅ 🐉) 🔜 💪 ⚙️ 🎂.
```Python hl_lines="19-29"
{!../../../docs_src/path_operation_advanced_configuration/tutorial004.py!}
```
## 🌖 📨
👆 🎲 ✔️ 👀 ❔ 📣 `response_model` &amp; `status_code` *➡ 🛠️*.
👈 🔬 🗃 🔃 👑 📨 *➡ 🛠️*.
👆 💪 📣 🌖 📨 ⏮️ 👫 🏷, 👔 📟, ♒️.
📤 🎂 📃 📥 🧾 🔃 ⚫️, 👆 💪 ✍ ⚫️ [🌖 📨 🗄](./additional-responses.md){.internal-link target=_blank}.
## 🗄 ➕
🕐❔ 👆 📣 *➡ 🛠️* 👆 🈸, **FastAPI** 🔁 🏗 🔗 🗃 🔃 👈 *➡ 🛠️* 🔌 🗄 🔗.
!!! note "📡 ℹ"
🗄 🔧 ⚫️ 🤙 <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object" class="external-link" target="_blank">🛠️ 🎚</a>.
⚫️ ✔️ 🌐 ℹ 🔃 *➡ 🛠️* &amp; ⚙️ 🏗 🏧 🧾.
⚫️ 🔌 `tags`, `parameters`, `requestBody`, `responses`, ♒️.
👉 *➡ 🛠️*-🎯 🗄 🔗 🛎 🏗 🔁 **FastAPI**, ✋️ 👆 💪 ↔ ⚫️.
!!! tip
👉 🔅 🎚 ↔ ☝.
🚥 👆 🕴 💪 📣 🌖 📨, 🌅 🏪 🌌 ⚫️ ⏮️ [🌖 📨 🗄](./additional-responses.md){.internal-link target=_blank}.
👆 💪 ↔ 🗄 🔗 *➡ 🛠️* ⚙️ 🔢 `openapi_extra`.
### 🗄 ↔
👉 `openapi_extra` 💪 👍, 🖼, 📣 [🗄 ↔](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions):
```Python hl_lines="6"
{!../../../docs_src/path_operation_advanced_configuration/tutorial005.py!}
```
🚥 👆 📂 🏧 🛠️ 🩺, 👆 ↔ 🔜 🎦 🆙 🔝 🎯 *➡ 🛠️*.
<img src="/img/tutorial/path-operation-advanced-configuration/image01.png">
&amp; 🚥 👆 👀 📉 🗄 ( `/openapi.json` 👆 🛠️), 👆 🔜 👀 👆 ↔ 🍕 🎯 *➡ 🛠️* 💁‍♂️:
```JSON hl_lines="22"
{
"openapi": "3.0.2",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/items/": {
"get": {
"summary": "Read Items",
"operationId": "read_items_items__get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
}
},
"x-aperture-labs-portal": "blue"
}
}
}
}
```
### 🛃 🗄 *➡ 🛠️* 🔗
📖 `openapi_extra` 🔜 🙇 🔗 ⏮️ 🔁 🏗 🗄 🔗 *➡ 🛠️*.
, 👆 💪 🚮 🌖 💽 🔁 🏗 🔗.
🖼, 👆 💪 💭 ✍ &amp; ✔ 📨 ⏮️ 👆 👍 📟, 🍵 ⚙️ 🏧 ⚒ FastAPI ⏮️ Pydantic, ✋️ 👆 💪 💚 🔬 📨 🗄 🔗.
👆 💪 👈 ⏮️ `openapi_extra`:
```Python hl_lines="20-37 39-40"
{!../../../docs_src/path_operation_advanced_configuration/tutorial006.py!}
```
👉 🖼, 👥 🚫 📣 🙆 Pydantic 🏷. 👐, 📨 💪 🚫 <abbr title="converted from some plain format, like bytes, into Python objects">🎻</abbr> 🎻, ⚫️ ✍ 🔗 `bytes`, &amp; 🔢 `magic_data_reader()` 🔜 🈚 🎻 ⚫️ 🌌.
👐, 👥 💪 📣 📈 🔗 📨 💪.
### 🛃 🗄 🎚 🆎
⚙️ 👉 🎏 🎱, 👆 💪 ⚙️ Pydantic 🏷 🔬 🎻 🔗 👈 ⤴️ 🔌 🛃 🗄 🔗 📄 *➡ 🛠️*.
&amp; 👆 💪 👉 🚥 💽 🆎 📨 🚫 🎻.
🖼, 👉 🈸 👥 🚫 ⚙️ FastAPI 🛠️ 🛠️ ⚗ 🎻 🔗 ⚪️➡️ Pydantic 🏷 🚫 🏧 🔬 🎻. 👐, 👥 📣 📨 🎚 🆎 📁, 🚫 🎻:
```Python hl_lines="17-22 24"
{!../../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
```
👐, 👐 👥 🚫 ⚙️ 🔢 🛠️ 🛠️, 👥 ⚙️ Pydantic 🏷 ❎ 🏗 🎻 🔗 💽 👈 👥 💚 📨 📁.
⤴️ 👥 ⚙️ 📨 🔗, &amp; ⚗ 💪 `bytes`. 👉 ⛓ 👈 FastAPI 🏆 🚫 🔄 🎻 📨 🚀 🎻.
&amp; ⤴️ 👆 📟, 👥 🎻 👈 📁 🎚 🔗, &amp; ⤴️ 👥 🔄 ⚙️ 🎏 Pydantic 🏷 ✔ 📁 🎚:
```Python hl_lines="26-33"
{!../../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
```
!!! tip
📥 👥 🏤-⚙️ 🎏 Pydantic 🏷.
✋️ 🎏 🌌, 👥 💪 ✔️ ✔ ⚫️ 🎏 🌌.

33
docs/em/docs/advanced/response-change-status-code.md

@ -0,0 +1,33 @@
# 📨 - 🔀 👔 📟
👆 🎲 ✍ ⏭ 👈 👆 💪 ⚒ 🔢 [📨 👔 📟](../tutorial/response-status-code.md){.internal-link target=_blank}.
✋️ 💼 👆 💪 📨 🎏 👔 📟 🌘 🔢.
## ⚙️ 💼
🖼, 🌈 👈 👆 💚 📨 🇺🇸🔍 👔 📟 "👌" `200` 🔢.
✋️ 🚥 💽 🚫 🔀, 👆 💚 ✍ ⚫️, &amp; 📨 🇺🇸🔍 👔 📟 "✍" `201`.
✋️ 👆 💚 💪 ⛽ &amp; 🗜 💽 👆 📨 ⏮️ `response_model`.
📚 💼, 👆 💪 ⚙️ `Response` 🔢.
## ⚙️ `Response` 🔢
👆 💪 📣 🔢 🆎 `Response` 👆 *➡ 🛠️ 🔢* (👆 💪 🍪 &amp; 🎚).
&amp; ⤴️ 👆 💪 ⚒ `status_code` 👈 *🔀* 📨 🎚.
```Python hl_lines="1 9 12"
{!../../../docs_src/response_change_status_code/tutorial001.py!}
```
&amp; ⤴️ 👆 💪 📨 🙆 🎚 👆 💪, 👆 🛎 🔜 ( `dict`, 💽 🏷, ♒️).
&amp; 🚥 👆 📣 `response_model`, ⚫️ 🔜 ⚙️ ⛽ &amp; 🗜 🎚 👆 📨.
**FastAPI** 🔜 ⚙️ 👈 *🔀* 📨 ⚗ 👔 📟 (🍪 &amp; 🎚), &amp; 🔜 🚮 👫 🏁 📨 👈 🔌 💲 👆 📨, ⛽ 🙆 `response_model`.
👆 💪 📣 `Response` 🔢 🔗, &amp; ⚒ 👔 📟 👫. ✋️ ✔️ 🤯 👈 🏁 1️⃣ ⚒ 🔜 🏆.

49
docs/em/docs/advanced/response-cookies.md

@ -0,0 +1,49 @@
# 📨 🍪
## ⚙️ `Response` 🔢
👆 💪 📣 🔢 🆎 `Response` 👆 *➡ 🛠️ 🔢*.
&amp; ⤴️ 👆 💪 ⚒ 🍪 👈 *🔀* 📨 🎚.
```Python hl_lines="1 8-9"
{!../../../docs_src/response_cookies/tutorial002.py!}
```
&amp; ⤴️ 👆 💪 📨 🙆 🎚 👆 💪, 👆 🛎 🔜 ( `dict`, 💽 🏷, ♒️).
&amp; 🚥 👆 📣 `response_model`, ⚫️ 🔜 ⚙️ ⛽ &amp; 🗜 🎚 👆 📨.
**FastAPI** 🔜 ⚙️ 👈 *🔀* 📨 ⚗ 🍪 (🎚 &amp; 👔 📟), &amp; 🔜 🚮 👫 🏁 📨 👈 🔌 💲 👆 📨, ⛽ 🙆 `response_model`.
👆 💪 📣 `Response` 🔢 🔗, &amp; ⚒ 🍪 (&amp; 🎚) 👫.
## 📨 `Response` 🔗
👆 💪 ✍ 🍪 🕐❔ 🛬 `Response` 🔗 👆 📟.
👈, 👆 💪 ✍ 📨 🔬 [📨 📨 🔗](response-directly.md){.internal-link target=_blank}.
⤴️ ⚒ 🍪 ⚫️, &amp; ⤴️ 📨 ⚫️:
```Python hl_lines="10-12"
{!../../../docs_src/response_cookies/tutorial001.py!}
```
!!! tip
✔️ 🤯 👈 🚥 👆 📨 📨 🔗 ↩️ ⚙️ `Response` 🔢, FastAPI 🔜 📨 ⚫️ 🔗.
, 👆 🔜 ✔️ ⚒ 💭 👆 💽 ☑ 🆎. 🤶 Ⓜ. ⚫️ 🔗 ⏮️ 🎻, 🚥 👆 🛬 `JSONResponse`.
&amp; 👈 👆 🚫 📨 🙆 📊 👈 🔜 ✔️ ⛽ `response_model`.
### 🌅 ℹ
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.responses import Response` ⚖️ `from starlette.responses import JSONResponse`.
**FastAPI** 🚚 🎏 `starlette.responses` `fastapi.responses` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃.
&amp; `Response` 💪 ⚙️ 🛎 ⚒ 🎚 &amp; 🍪, **FastAPI** 🚚 ⚫️ `fastapi.Response`.
👀 🌐 💪 🔢 &amp; 🎛, ✅ <a href="https://www.starlette.io/responses/#set-cookie" class="external-link" target="_blank">🧾 💃</a>.

63
docs/em/docs/advanced/response-directly.md

@ -0,0 +1,63 @@
# 📨 📨 🔗
🕐❔ 👆 ✍ **FastAPI** *➡ 🛠️* 👆 💪 🛎 📨 🙆 📊 ⚪️➡️ ⚫️: `dict`, `list`, Pydantic 🏷, 💽 🏷, ♒️.
🔢, **FastAPI** 🔜 🔁 🗜 👈 📨 💲 🎻 ⚙️ `jsonable_encoder` 🔬 [🎻 🔗 🔢](../tutorial/encoder.md){.internal-link target=_blank}.
⤴️, ⛅ 🎑, ⚫️ 🔜 🚮 👈 🎻-🔗 💽 (✅ `dict`) 🔘 `JSONResponse` 👈 🔜 ⚙️ 📨 📨 👩‍💻.
✋️ 👆 💪 📨 `JSONResponse` 🔗 ⚪️➡️ 👆 *➡ 🛠️*.
⚫️ 💪 ⚠, 🖼, 📨 🛃 🎚 ⚖️ 🍪.
## 📨 `Response`
👐, 👆 💪 📨 🙆 `Response` ⚖️ 🙆 🎧-🎓 ⚫️.
!!! tip
`JSONResponse` ⚫️ 🎧-🎓 `Response`.
&amp; 🕐❔ 👆 📨 `Response`, **FastAPI** 🔜 🚶‍♀️ ⚫️ 🔗.
⚫️ 🏆 🚫 🙆 💽 🛠️ ⏮️ Pydantic 🏷, ⚫️ 🏆 🚫 🗜 🎚 🙆 🆎, ♒️.
👉 🤝 👆 📚 💪. 👆 💪 📨 🙆 📊 🆎, 🔐 🙆 💽 📄 ⚖️ 🔬, ♒️.
## ⚙️ `jsonable_encoder` `Response`
↩️ **FastAPI** 🚫 🙆 🔀 `Response` 👆 📨, 👆 ✔️ ⚒ 💭 ⚫️ 🎚 🔜 ⚫️.
🖼, 👆 🚫🔜 🚮 Pydantic 🏷 `JSONResponse` 🍵 🥇 🏭 ⚫️ `dict` ⏮️ 🌐 📊 🆎 (💖 `datetime`, `UUID`, ♒️) 🗜 🎻-🔗 🆎.
📚 💼, 👆 💪 ⚙️ `jsonable_encoder` 🗜 👆 📊 ⏭ 🚶‍♀️ ⚫️ 📨:
```Python hl_lines="6-7 21-22"
{!../../../docs_src/response_directly/tutorial001.py!}
```
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.responses import JSONResponse`.
**FastAPI** 🚚 🎏 `starlette.responses` `fastapi.responses` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃.
## 🛬 🛃 `Response`
🖼 🔛 🎦 🌐 🍕 👆 💪, ✋️ ⚫️ 🚫 📶 ⚠, 👆 💪 ✔️ 📨 `item` 🔗, &amp; **FastAPI** 🔜 🚮 ⚫️ `JSONResponse` 👆, 🏭 ⚫️ `dict`, ♒️. 🌐 👈 🔢.
🔜, ➡️ 👀 ❔ 👆 💪 ⚙️ 👈 📨 🛃 📨.
➡️ 💬 👈 👆 💚 📨 <a href="https://en.wikipedia.org/wiki/XML" class="external-link" target="_blank">📂</a> 📨.
👆 💪 🚮 👆 📂 🎚 🎻, 🚮 ⚫️ `Response`, &amp; 📨 ⚫️:
```Python hl_lines="1 18"
{!../../../docs_src/response_directly/tutorial002.py!}
```
## 🗒
🕐❔ 👆 📨 `Response` 🔗 🚮 📊 🚫 ✔, 🗜 (🎻), 🚫 📄 🔁.
✋️ 👆 💪 📄 ⚫️ 🔬 [🌖 📨 🗄](additional-responses.md){.internal-link target=_blank}.
👆 💪 👀 ⏪ 📄 ❔ ⚙️/📣 👉 🛃 `Response`Ⓜ ⏪ ✔️ 🏧 💽 🛠️, 🧾, ♒️.

42
docs/em/docs/advanced/response-headers.md

@ -0,0 +1,42 @@
# 📨 🎚
## ⚙️ `Response` 🔢
👆 💪 📣 🔢 🆎 `Response` 👆 *➡ 🛠️ 🔢* (👆 💪 🍪).
&amp; ⤴️ 👆 💪 ⚒ 🎚 👈 *🔀* 📨 🎚.
```Python hl_lines="1 7-8"
{!../../../docs_src/response_headers/tutorial002.py!}
```
&amp; ⤴️ 👆 💪 📨 🙆 🎚 👆 💪, 👆 🛎 🔜 ( `dict`, 💽 🏷, ♒️).
&amp; 🚥 👆 📣 `response_model`, ⚫️ 🔜 ⚙️ ⛽ &amp; 🗜 🎚 👆 📨.
**FastAPI** 🔜 ⚙️ 👈 *🔀* 📨 ⚗ 🎚 (🍪 &amp; 👔 📟), &amp; 🔜 🚮 👫 🏁 📨 👈 🔌 💲 👆 📨, ⛽ 🙆 `response_model`.
👆 💪 📣 `Response` 🔢 🔗, &amp; ⚒ 🎚 (&amp; 🍪) 👫.
## 📨 `Response` 🔗
👆 💪 🚮 🎚 🕐❔ 👆 📨 `Response` 🔗.
✍ 📨 🔬 [📨 📨 🔗](response-directly.md){.internal-link target=_blank} &amp; 🚶‍♀️ 🎚 🌖 🔢:
```Python hl_lines="10-12"
{!../../../docs_src/response_headers/tutorial001.py!}
```
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.responses import Response` ⚖️ `from starlette.responses import JSONResponse`.
**FastAPI** 🚚 🎏 `starlette.responses` `fastapi.responses` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃.
&amp; `Response` 💪 ⚙️ 🛎 ⚒ 🎚 &amp; 🍪, **FastAPI** 🚚 ⚫️ `fastapi.Response`.
## 🛃 🎚
✔️ 🤯 👈 🛃 © 🎚 💪 🚮 <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">⚙️ '✖-' 🔡</a>.
✋️ 🚥 👆 ✔️ 🛃 🎚 👈 👆 💚 👩‍💻 🖥 💪 👀, 👆 💪 🚮 👫 👆 ⚜ 📳 (✍ 🌅 [⚜ (✖️-🇨🇳 ℹ 🤝)](../tutorial/cors.md){.internal-link target=_blank}), ⚙️ 🔢 `expose_headers` 📄 <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">💃 ⚜ 🩺</a>.

113
docs/em/docs/advanced/security/http-basic-auth.md

@ -0,0 +1,113 @@
# 🇺🇸🔍 🔰 🔐
🙅 💼, 👆 💪 ⚙️ 🇺🇸🔍 🔰 🔐.
🇺🇸🔍 🔰 🔐, 🈸 ⌛ 🎚 👈 🔌 🆔 &amp; 🔐.
🚥 ⚫️ 🚫 📨 ⚫️, ⚫️ 📨 🇺🇸🔍 4️⃣0️⃣1️⃣ "⛔" ❌.
&amp; 📨 🎚 `WWW-Authenticate` ⏮️ 💲 `Basic`, &amp; 📦 `realm` 🔢.
👈 💬 🖥 🎦 🛠️ 📋 🆔 &amp; 🔐.
⤴️, 🕐❔ 👆 🆎 👈 🆔 &amp; 🔐, 🖥 📨 👫 🎚 🔁.
## 🙅 🇺🇸🔍 🔰 🔐
* 🗄 `HTTPBasic` &amp; `HTTPBasicCredentials`.
* ✍ "`security` ⚖" ⚙️ `HTTPBasic`.
* ⚙️ 👈 `security` ⏮️ 🔗 👆 *➡ 🛠️*.
* ⚫️ 📨 🎚 🆎 `HTTPBasicCredentials`:
* ⚫️ 🔌 `username` &amp; `password` 📨.
```Python hl_lines="2 6 10"
{!../../../docs_src/security/tutorial006.py!}
```
🕐❔ 👆 🔄 📂 📛 🥇 🕰 (⚖️ 🖊 "🛠️" 🔼 🩺) 🖥 🔜 💭 👆 👆 🆔 &amp; 🔐:
<img src="/img/tutorial/security/image12.png">
## ✅ 🆔
📥 🌅 🏁 🖼.
⚙️ 🔗 ✅ 🚥 🆔 &amp; 🔐 ☑.
👉, ⚙️ 🐍 🐩 🕹 <a href="https://docs.python.org/3/library/secrets.html" class="external-link" target="_blank">`secrets`</a> ✅ 🆔 &amp; 🔐.
`secrets.compare_digest()` 💪 ✊ `bytes` ⚖️ `str` 👈 🕴 🔌 🔠 🦹 (🕐 🇪🇸), 👉 ⛓ ⚫️ 🚫🔜 👷 ⏮️ 🦹 💖 `á`, `Sebastián`.
🍵 👈, 👥 🥇 🗜 `username` &amp; `password` `bytes` 🔢 👫 ⏮️ 🔠-8️⃣.
⤴️ 👥 💪 ⚙️ `secrets.compare_digest()` 🚚 👈 `credentials.username` `"stanleyjobson"`, &amp; 👈 `credentials.password` `"swordfish"`.
```Python hl_lines="1 11-21"
{!../../../docs_src/security/tutorial007.py!}
```
👉 🔜 🎏:
```Python
if not (credentials.username == "stanleyjobson") or not (credentials.password == "swordfish"):
# Return some error
...
```
✋️ ⚙️ `secrets.compare_digest()` ⚫️ 🔜 🔐 🛡 🆎 👊 🤙 "🕰 👊".
### ⏲ 👊
✋️ ⚫️❔ "⏲ 👊"❓
➡️ 🌈 👊 🔄 💭 🆔 &amp; 🔐.
&amp; 👫 📨 📨 ⏮️ 🆔 `johndoe` &amp; 🔐 `love123`.
⤴️ 🐍 📟 👆 🈸 🔜 🌓 🕳 💖:
```Python
if "johndoe" == "stanleyjobson" and "love123" == "swordfish":
...
```
✋️ ▶️️ 🙍 🐍 🔬 🥇 `j` `johndoe` 🥇 `s` `stanleyjobson`, ⚫️ 🔜 📨 `False`, ↩️ ⚫️ ⏪ 💭 👈 📚 2️⃣ 🎻 🚫 🎏, 💭 👈 "📤 🙅‍♂ 💪 🗑 🌅 📊 ⚖ 🎂 🔤". &amp; 👆 🈸 🔜 💬 "❌ 👩‍💻 ⚖️ 🔐".
✋️ ⤴️ 👊 🔄 ⏮️ 🆔 `stanleyjobsox` &amp; 🔐 `love123`.
&amp; 👆 🈸 📟 🔨 🕳 💖:
```Python
if "stanleyjobsox" == "stanleyjobson" and "love123" == "swordfish":
...
```
🐍 🔜 ✔️ 🔬 🎂 `stanleyjobso` 👯‍♂️ `stanleyjobsox` &amp; `stanleyjobson` ⏭ 🤔 👈 👯‍♂️ 🎻 🚫 🎏. ⚫️ 🔜 ✊ ➕ ⏲ 📨 🔙 "❌ 👩‍💻 ⚖️ 🔐".
#### 🕰 ❔ ℹ 👊
👈 ☝, 👀 👈 💽 ✊ ⏲ 📏 📨 "❌ 👩‍💻 ⚖️ 🔐" 📨, 👊 🔜 💭 👈 👫 🤚 _🕳_ ▶️️, ▶️ 🔤 ▶️️.
&amp; ⤴️ 👫 💪 🔄 🔄 🤔 👈 ⚫️ 🎲 🕳 🌖 🎏 `stanleyjobsox` 🌘 `johndoe`.
#### "🕴" 👊
↗️, 👊 🔜 🚫 🔄 🌐 👉 ✋, 👫 🔜 ✍ 📋 ⚫️, 🎲 ⏮️ 💯 ⚖️ 💯 💯 📍 🥈. &amp; 🔜 🤚 1️⃣ ➕ ☑ 🔤 🕰.
✋️ 🔨 👈, ⏲ ⚖️ 📆 👊 🔜 ✔️ 💭 ☑ 🆔 &amp; 🔐, ⏮️ "ℹ" 👆 🈸, ⚙️ 🕰 ✊ ❔.
#### 🔧 ⚫️ ⏮️ `secrets.compare_digest()`
✋️ 👆 📟 👥 🤙 ⚙️ `secrets.compare_digest()`.
📏, ⚫️ 🔜 ✊ 🎏 🕰 🔬 `stanleyjobsox` `stanleyjobson` 🌘 ⚫️ ✊ 🔬 `johndoe` `stanleyjobson`. &amp; 🎏 🔐.
👈 🌌, ⚙️ `secrets.compare_digest()` 👆 🈸 📟, ⚫️ 🔜 🔒 🛡 👉 🎂 ↔ 💂‍♂ 👊.
### 📨 ❌
⏮️ 🔍 👈 🎓 ❌, 📨 `HTTPException` ⏮️ 👔 📟 4️⃣0️⃣1️⃣ (🎏 📨 🕐❔ 🙅‍♂ 🎓 🚚) &amp; 🚮 🎚 `WWW-Authenticate` ⚒ 🖥 🎦 💳 📋 🔄:
```Python hl_lines="23-27"
{!../../../docs_src/security/tutorial007.py!}
```

16
docs/em/docs/advanced/security/index.md

@ -0,0 +1,16 @@
# 🏧 💂‍♂
## 🌖 ⚒
📤 ➕ ⚒ 🍵 💂‍♂ ↖️ ⚪️➡️ 🕐 📔 [🔰 - 👩‍💻 🦮: 💂‍♂](../../tutorial/security/){.internal-link target=_blank}.
!!! tip
⏭ 📄 **🚫 🎯 "🏧"**.
&amp; ⚫️ 💪 👈 👆 ⚙️ 💼, ⚗ 1️⃣ 👫.
## ✍ 🔰 🥇
⏭ 📄 🤔 👆 ⏪ ✍ 👑 [🔰 - 👩‍💻 🦮: 💂‍♂](../../tutorial/security/){.internal-link target=_blank}.
👫 🌐 ⚓️ 🔛 🎏 🔧, ✋️ ✔ ➕ 🛠️.

269
docs/em/docs/advanced/security/oauth2-scopes.md

@ -0,0 +1,269 @@
# Oauth2️⃣ ↔
👆 💪 ⚙️ Oauth2️⃣ ↔ 🔗 ⏮️ **FastAPI**, 👫 🛠️ 👷 💎.
👉 🔜 ✔ 👆 ✔️ 🌖 👌-🧽 ✔ ⚙️, 📄 Oauth2️⃣ 🐩, 🛠️ 🔘 👆 🗄 🈸 (&amp; 🛠️ 🩺).
Oauth2️⃣ ⏮️ ↔ 🛠️ ⚙️ 📚 🦏 🤝 🐕‍🦺, 💖 👱📔, 🇺🇸🔍, 📂, 🤸‍♂, 👱📔, ♒️. 👫 ⚙️ ⚫️ 🚚 🎯 ✔ 👩‍💻 &amp; 🈸.
🔠 🕰 👆 "🕹 ⏮️" 👱📔, 🇺🇸🔍, 📂, 🤸‍♂, 👱📔, 👈 🈸 ⚙️ Oauth2️⃣ ⏮️ ↔.
👉 📄 👆 🔜 👀 ❔ 🛠️ 🤝 &amp; ✔ ⏮️ 🎏 Oauth2️⃣ ⏮️ ↔ 👆 **FastAPI** 🈸.
!!! warning
👉 🌅 ⚖️ 🌘 🏧 📄. 🚥 👆 ▶️, 👆 💪 🚶 ⚫️.
👆 🚫 🎯 💪 Oauth2️⃣ ↔, &amp; 👆 💪 🍵 🤝 &amp; ✔ 👐 👆 💚.
✋️ Oauth2️⃣ ⏮️ ↔ 💪 🎆 🛠️ 🔘 👆 🛠️ (⏮️ 🗄) &amp; 👆 🛠️ 🩺.
👐, 👆 🛠️ 📚 ↔, ⚖️ 🙆 🎏 💂‍♂/✔ 📄, 👐 👆 💪, 👆 📟.
📚 💼, Oauth2️⃣ ⏮️ ↔ 💪 👹.
✋️ 🚥 👆 💭 👆 💪 ⚫️, ⚖️ 👆 😟, 🚧 👂.
## Oauth2️⃣ ↔ &amp; 🗄
Oauth2️⃣ 🔧 🔬 "↔" 📇 🎻 🎏 🚀.
🎚 🔠 👉 🎻 💪 ✔️ 🙆 📁, ✋️ 🔜 🚫 🔌 🚀.
👫 ↔ 🎨 "✔".
🗄 (✅ 🛠️ 🩺), 👆 💪 🔬 "💂‍♂ ⚖".
🕐❔ 1️⃣ 👫 💂‍♂ ⚖ ⚙️ Oauth2️⃣, 👆 💪 📣 &amp; ⚙️ ↔.
🔠 "↔" 🎻 (🍵 🚀).
👫 🛎 ⚙️ 📣 🎯 💂‍♂ ✔, 🖼:
* `users:read` ⚖️ `users:write` ⚠ 🖼.
* `instagram_basic` ⚙️ 👱📔 / 👱📔.
* `https://www.googleapis.com/auth/drive` ⚙️ 🇺🇸🔍.
!!! info
Oauth2️⃣ "↔" 🎻 👈 📣 🎯 ✔ ✔.
⚫️ 🚫 🤔 🚥 ⚫️ ✔️ 🎏 🦹 💖 `:` ⚖️ 🚥 ⚫️ 📛.
👈 ℹ 🛠️ 🎯.
Oauth2️⃣ 👫 🎻.
## 🌐 🎑
🥇, ➡️ 🔜 👀 🍕 👈 🔀 ⚪️➡️ 🖼 👑 **🔰 - 👩‍💻 🦮** [Oauth2️⃣ ⏮️ 🔐 (&amp; 🔁), 📨 ⏮️ 🥙 🤝](../../tutorial/security/oauth2-jwt.md){.internal-link target=_blank}. 🔜 ⚙️ Oauth2️⃣ ↔:
```Python hl_lines="2 4 8 12 46 64 105 107-115 121-124 128-134 139 153"
{!../../../docs_src/security/tutorial005.py!}
```
🔜 ➡️ 📄 👈 🔀 🔁 🔁.
## Oauth2️⃣ 💂‍♂ ⚖
🥇 🔀 👈 🔜 👥 📣 Oauth2️⃣ 💂‍♂ ⚖ ⏮️ 2️⃣ 💪 ↔, `me` &amp; `items`.
`scopes` 🔢 📨 `dict` ⏮️ 🔠 ↔ 🔑 &amp; 📛 💲:
```Python hl_lines="62-65"
{!../../../docs_src/security/tutorial005.py!}
```
↩️ 👥 🔜 📣 📚 ↔, 👫 🔜 🎦 🆙 🛠️ 🩺 🕐❔ 👆 🕹-/✔.
&amp; 👆 🔜 💪 🖊 ❔ ↔ 👆 💚 🤝 🔐: `me` &amp; `items`.
👉 🎏 🛠️ ⚙️ 🕐❔ 👆 🤝 ✔ ⏪ 🚨 ⏮️ 👱📔, 🇺🇸🔍, 📂, ♒️:
<img src="/img/tutorial/security/image11.png">
## 🥙 🤝 ⏮️ ↔
🔜, 🔀 🤝 *➡ 🛠️* 📨 ↔ 📨.
👥 ⚙️ 🎏 `OAuth2PasswordRequestForm`. ⚫️ 🔌 🏠 `scopes` ⏮️ `list` `str`, ⏮️ 🔠 ↔ ⚫️ 📨 📨.
&amp; 👥 📨 ↔ 🍕 🥙 🤝.
!!! danger
🦁, 📥 👥 ❎ ↔ 📨 🔗 🤝.
✋️ 👆 🈸, 💂‍♂, 👆 🔜 ⚒ 💭 👆 🕴 🚮 ↔ 👈 👩‍💻 🤙 💪 ✔️, ⚖️ 🕐 👆 ✔️ 🔁.
```Python hl_lines="153"
{!../../../docs_src/security/tutorial005.py!}
```
## 📣 ↔ *➡ 🛠️* &amp; 🔗
🔜 👥 📣 👈 *➡ 🛠️* `/users/me/items/` 🚚 ↔ `items`.
👉, 👥 🗄 &amp; ⚙️ `Security` ⚪️➡️ `fastapi`.
👆 💪 ⚙️ `Security` 📣 🔗 (💖 `Depends`), ✋️ `Security` 📨 🔢 `scopes` ⏮️ 📇 ↔ (🎻).
👉 💼, 👥 🚶‍♀️ 🔗 🔢 `get_current_active_user` `Security` (🎏 🌌 👥 🔜 ⏮️ `Depends`).
✋️ 👥 🚶‍♀️ `list` ↔, 👉 💼 ⏮️ 1️⃣ ↔: `items` (⚫️ 💪 ✔️ 🌅).
&amp; 🔗 🔢 `get_current_active_user` 💪 📣 🎧-🔗, 🚫 🕴 ⏮️ `Depends` ✋️ ⏮️ `Security`. 📣 🚮 👍 🎧-🔗 🔢 (`get_current_user`), &amp; 🌖 ↔ 📄.
👉 💼, ⚫️ 🚚 ↔ `me` (⚫️ 💪 🚚 🌅 🌘 1️⃣ ↔).
!!! note
👆 🚫 🎯 💪 🚮 🎏 ↔ 🎏 🥉.
👥 🔨 ⚫️ 📥 🎦 ❔ **FastAPI** 🍵 ↔ 📣 🎏 🎚.
```Python hl_lines="4 139 166"
{!../../../docs_src/security/tutorial005.py!}
```
!!! info "📡 ℹ"
`Security` 🤙 🏿 `Depends`, &amp; ⚫️ ✔️ 1️⃣ ➕ 🔢 👈 👥 🔜 👀 ⏪.
✋️ ⚙️ `Security` ↩️ `Depends`, **FastAPI** 🔜 💭 👈 ⚫️ 💪 📣 💂‍♂ ↔, ⚙️ 👫 🔘, &amp; 📄 🛠️ ⏮️ 🗄.
✋️ 🕐❔ 👆 🗄 `Query`, `Path`, `Depends`, `Security` &amp; 🎏 ⚪️➡️ `fastapi`, 👈 🤙 🔢 👈 📨 🎁 🎓.
## ⚙️ `SecurityScopes`
🔜 ℹ 🔗 `get_current_user`.
👉 1️⃣ ⚙️ 🔗 🔛.
📥 👥 ⚙️ 🎏 Oauth2️⃣ ⚖ 👥 ✍ ⏭, 📣 ⚫️ 🔗: `oauth2_scheme`.
↩️ 👉 🔗 🔢 🚫 ✔️ 🙆 ↔ 📄 ⚫️, 👥 💪 ⚙️ `Depends` ⏮️ `oauth2_scheme`, 👥 🚫 ✔️ ⚙️ `Security` 🕐❔ 👥 🚫 💪 ✔ 💂‍♂ ↔.
👥 📣 🎁 🔢 🆎 `SecurityScopes`, 🗄 ⚪️➡️ `fastapi.security`.
👉 `SecurityScopes` 🎓 🎏 `Request` (`Request` ⚙️ 🤚 📨 🎚 🔗).
```Python hl_lines="8 105"
{!../../../docs_src/security/tutorial005.py!}
```
## ⚙️ `scopes`
🔢 `security_scopes` 🔜 🆎 `SecurityScopes`.
⚫️ 🔜 ✔️ 🏠 `scopes` ⏮️ 📇 ⚗ 🌐 ↔ ✔ ⚫️ &amp; 🌐 🔗 👈 ⚙️ 👉 🎧-🔗. 👈 ⛓, 🌐 "⚓️"... 👉 💪 🔊 😨, ⚫️ 🔬 🔄 ⏪ 🔛.
`security_scopes` 🎚 (🎓 `SecurityScopes`) 🚚 `scope_str` 🔢 ⏮️ 👁 🎻, 🔌 👈 ↔ 👽 🚀 (👥 🔜 ⚙️ ⚫️).
👥 ✍ `HTTPException` 👈 👥 💪 🏤-⚙️ (`raise`) ⏪ 📚 ☝.
👉 ⚠, 👥 🔌 ↔ 🚚 (🚥 🙆) 🎻 👽 🚀 (⚙️ `scope_str`). 👥 🚮 👈 🎻 ⚗ ↔ `WWW-Authenticate` 🎚 (👉 🍕 🔌).
```Python hl_lines="105 107-115"
{!../../../docs_src/security/tutorial005.py!}
```
## ✔ `username` &amp; 💽 💠
👥 ✔ 👈 👥 🤚 `username`, &amp; ⚗ ↔.
&amp; ⤴️ 👥 ✔ 👈 📊 ⏮️ Pydantic 🏷 (✊ `ValidationError` ⚠), &amp; 🚥 👥 🤚 ❌ 👂 🥙 🤝 ⚖️ ⚖ 📊 ⏮️ Pydantic, 👥 🤚 `HTTPException` 👥 ✍ ⏭.
👈, 👥 ℹ Pydantic 🏷 `TokenData` ⏮️ 🆕 🏠 `scopes`.
⚖ 📊 ⏮️ Pydantic 👥 💪 ⚒ 💭 👈 👥 ✔️, 🖼, ⚫️❔ `list` `str` ⏮️ ↔ &amp; `str` ⏮️ `username`.
↩️, 🖼, `dict`, ⚖️ 🕳 🙆, ⚫️ 💪 💔 🈸 ☝ ⏪, ⚒ ⚫️ 💂‍♂ ⚠.
👥 ✔ 👈 👥 ✔️ 👩‍💻 ⏮️ 👈 🆔, &amp; 🚥 🚫, 👥 🤚 👈 🎏 ⚠ 👥 ✍ ⏭.
```Python hl_lines="46 116-127"
{!../../../docs_src/security/tutorial005.py!}
```
## ✔ `scopes`
👥 🔜 ✔ 👈 🌐 ↔ ✔, 👉 🔗 &amp; 🌐 ⚓️ (🔌 *➡ 🛠️*), 🔌 ↔ 🚚 🤝 📨, ⏪ 🤚 `HTTPException`.
👉, 👥 ⚙️ `security_scopes.scopes`, 👈 🔌 `list` ⏮️ 🌐 👫 ↔ `str`.
```Python hl_lines="128-134"
{!../../../docs_src/security/tutorial005.py!}
```
## 🔗 🌲 &amp;
➡️ 📄 🔄 👉 🔗 🌲 &amp; ↔.
`get_current_active_user` 🔗 ✔️ 🎧-🔗 🔛 `get_current_user`, ↔ `"me"` 📣 `get_current_active_user` 🔜 🔌 📇 ✔ ↔ `security_scopes.scopes` 🚶‍♀️ `get_current_user`.
*➡ 🛠️* ⚫️ 📣 ↔, `"items"`, 👉 🔜 📇 `security_scopes.scopes` 🚶‍♀️ `get_current_user`.
📥 ❔ 🔗 🔗 &amp; ↔ 👀 💖:
* *➡ 🛠️* `read_own_items` ✔️:
* ✔ ↔ `["items"]` ⏮️ 🔗:
* `get_current_active_user`:
* 🔗 🔢 `get_current_active_user` ✔️:
* ✔ ↔ `["me"]` ⏮️ 🔗:
* `get_current_user`:
* 🔗 🔢 `get_current_user` ✔️:
* 🙅‍♂ ↔ ✔ ⚫️.
* 🔗 ⚙️ `oauth2_scheme`.
* `security_scopes` 🔢 🆎 `SecurityScopes`:
* 👉 `security_scopes` 🔢 ✔️ 🏠 `scopes` ⏮️ `list` ⚗ 🌐 👫 ↔ 📣 🔛,:
* `security_scopes.scopes` 🔜 🔌 `["me", "items"]` *➡ 🛠️* `read_own_items`.
* `security_scopes.scopes` 🔜 🔌 `["me"]` *➡ 🛠️* `read_users_me`, ↩️ ⚫️ 📣 🔗 `get_current_active_user`.
* `security_scopes.scopes` 🔜 🔌 `[]` (🕳) *➡ 🛠️* `read_system_status`, ↩️ ⚫️ 🚫 📣 🙆 `Security` ⏮️ `scopes`, &amp; 🚮 🔗, `get_current_user`, 🚫 📣 🙆 `scope` 👯‍♂️.
!!! tip
&amp; "🎱" 👜 📥 👈 `get_current_user` 🔜 ✔️ 🎏 📇 `scopes` ✅ 🔠 *➡ 🛠️*.
🌐 ⚓️ 🔛 `scopes` 📣 🔠 *➡ 🛠️* &amp; 🔠 🔗 🔗 🌲 👈 🎯 *➡ 🛠️*.
## 🌖 ℹ 🔃 `SecurityScopes`
👆 💪 ⚙️ `SecurityScopes` 🙆 ☝, &amp; 💗 🥉, ⚫️ 🚫 ✔️ "🌱" 🔗.
⚫️ 🔜 🕧 ✔️ 💂‍♂ ↔ 📣 ⏮️ `Security` 🔗 &amp; 🌐 ⚓️ **👈 🎯** *➡ 🛠️* &amp; **👈 🎯** 🔗 🌲.
↩️ `SecurityScopes` 🔜 ✔️ 🌐 ↔ 📣 ⚓️, 👆 💪 ⚙️ ⚫️ ✔ 👈 🤝 ✔️ 🚚 ↔ 🇨🇫 🔗 🔢, &amp; ⤴️ 📣 🎏 ↔ 📄 🎏 *➡ 🛠️*.
👫 🔜 ✅ ➡ 🔠 *➡ 🛠️*.
## ✅ ⚫️
🚥 👆 📂 🛠️ 🩺, 👆 💪 🔓 &amp; ✔ ❔ ↔ 👆 💚 ✔.
<img src="/img/tutorial/security/image11.png">
🚥 👆 🚫 🖊 🙆 ↔, 👆 🔜 "🔓", ✋️ 🕐❔ 👆 🔄 🔐 `/users/me/` ⚖️ `/users/me/items/` 👆 🔜 🤚 ❌ 💬 👈 👆 🚫 ✔️ 🥃 ✔. 👆 🔜 💪 🔐 `/status/`.
&amp; 🚥 👆 🖊 ↔ `me` ✋️ 🚫 ↔ `items`, 👆 🔜 💪 🔐 `/users/me/` ✋️ 🚫 `/users/me/items/`.
👈 ⚫️❔ 🔜 🔨 🥉 🥳 🈸 👈 🔄 🔐 1️⃣ 👫 *➡ 🛠️* ⏮️ 🤝 🚚 👩‍💻, ⚓️ 🔛 ❔ 📚 ✔ 👩‍💻 🤝 🈸.
## 🔃 🥉 🥳 🛠️
👉 🖼 👥 ⚙️ Oauth2️⃣ "🔐" 💧.
👉 ☑ 🕐❔ 👥 🚨 👆 👍 🈸, 🎲 ⏮️ 👆 👍 🕸.
↩️ 👥 💪 💙 ⚫️ 📨 `username` &amp; `password`, 👥 🎛 ⚫️.
✋️ 🚥 👆 🏗 Oauth2️⃣ 🈸 👈 🎏 🔜 🔗 (➡, 🚥 👆 🏗 🤝 🐕‍🦺 🌓 👱📔, 🇺🇸🔍, 📂, ♒️.) 👆 🔜 ⚙️ 1️⃣ 🎏 💧.
🌅 ⚠ 🔑 💧.
🏆 🔐 📟 💧, ✋️ 🌖 🏗 🛠️ ⚫️ 🚚 🌅 📶. ⚫️ 🌅 🏗, 📚 🐕‍🦺 🔚 🆙 ✔ 🔑 💧.
!!! note
⚫️ ⚠ 👈 🔠 🤝 🐕‍🦺 📛 👫 💧 🎏 🌌, ⚒ ⚫️ 🍕 👫 🏷.
✋️ 🔚, 👫 🛠️ 🎏 Oauth2️⃣ 🐩.
**FastAPI** 🔌 🚙 🌐 👫 Oauth2️⃣ 🤝 💧 `fastapi.security.oauth2`.
## `Security` 👨‍🎨 `dependencies`
🎏 🌌 👆 💪 🔬 `list` `Depends` 👨‍🎨 `dependencies` 🔢 (🔬 [🔗 ➡ 🛠️ 👨‍🎨](../../tutorial/dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}), 👆 💪 ⚙️ `Security` ⏮️ `scopes` 📤.

382
docs/em/docs/advanced/settings.md

@ -0,0 +1,382 @@
# ⚒ &amp; 🌐 🔢
📚 💼 👆 🈸 💪 💪 🔢 ⚒ ⚖️ 📳, 🖼 ㊙ 🔑, 💽 🎓, 🎓 📧 🐕‍🦺, ♒️.
🏆 👫 ⚒ 🔢 (💪 🔀), 💖 💽 📛. &amp; 📚 💪 🚿, 💖 ㊙.
👉 🤔 ⚫️ ⚠ 🚚 👫 🌐 🔢 👈 ✍ 🈸.
## 🌐 🔢
!!! tip
🚥 👆 ⏪ 💭 ⚫️❔ "🌐 🔢" &amp; ❔ ⚙️ 👫, 💭 🆓 🚶 ⏭ 📄 🔛.
<a href="https://en.wikipedia.org/wiki/Environment_variable" class="external-link" target="_blank">🌐 🔢</a> (💭 "🇨🇻 {") 🔢 👈 🖖 🏞 🐍 📟, 🏃‍♂ ⚙️, &amp; 💪 ✍ 👆 🐍 📟 (⚖️ 🎏 📋 👍).
👆 💪 ✍ &amp; ⚙️ 🌐 🔢 🐚, 🍵 💆‍♂ 🐍:
=== "💾, 🇸🇻, 🚪 🎉"
<div class="termy">
```console
// You could create an env var MY_NAME with
$ export MY_NAME="Wade Wilson"
// Then you could use it with other programs, like
$ echo "Hello $MY_NAME"
Hello Wade Wilson
```
</div>
=== "🚪 📋"
<div class="termy">
```console
// Create an env var MY_NAME
$ $Env:MY_NAME = "Wade Wilson"
// Use it with other programs, like
$ echo "Hello $Env:MY_NAME"
Hello Wade Wilson
```
</div>
### ✍ 🇨🇻 {🐍
👆 💪 ✍ 🌐 🔢 🏞 🐍, 📶 (⚖️ ⏮️ 🙆 🎏 👩‍🔬), &amp; ⤴️ ✍ 👫 🐍.
🖼 👆 💪 ✔️ 📁 `main.py` ⏮️:
```Python hl_lines="3"
import os
name = os.getenv("MY_NAME", "World")
print(f"Hello {name} from Python")
```
!!! tip
🥈 ❌ <a href="https://docs.python.org/3.8/library/os.html#os.getenv" class="external-link" target="_blank">`os.getenv()`</a> 🔢 💲 📨.
🚥 🚫 🚚, ⚫️ `None` 🔢, 📥 👥 🚚 `"World"` 🔢 💲 ⚙️.
⤴️ 👆 💪 🤙 👈 🐍 📋:
<div class="termy">
```console
// Here we don't set the env var yet
$ python main.py
// As we didn't set the env var, we get the default value
Hello World from Python
// But if we create an environment variable first
$ export MY_NAME="Wade Wilson"
// And then call the program again
$ python main.py
// Now it can read the environment variable
Hello Wade Wilson from Python
```
</div>
🌐 🔢 💪 ⚒ 🏞 📟, ✋️ 💪 ✍ 📟, &amp; 🚫 ✔️ 🏪 (💕 `git`) ⏮️ 🎂 📁, ⚫️ ⚠ ⚙️ 👫 📳 ⚖️ ⚒.
👆 💪 ✍ 🌐 🔢 🕴 🎯 📋 👼, 👈 🕴 💪 👈 📋, &amp; 🕴 🚮 📐.
👈, ✍ ⚫️ ▶️️ ⏭ 📋 ⚫️, 🔛 🎏 ⏸:
<div class="termy">
```console
// Create an env var MY_NAME in line for this program call
$ MY_NAME="Wade Wilson" python main.py
// Now it can read the environment variable
Hello Wade Wilson from Python
// The env var no longer exists afterwards
$ python main.py
Hello World from Python
```
</div>
!!! tip
👆 💪 ✍ 🌅 🔃 ⚫️ <a href="https://12factor.net/config" class="external-link" target="_blank">1️⃣2️⃣-⚖ 📱: 📁</a>.
### 🆎 &amp; 🔬
👫 🌐 🔢 💪 🕴 🍵 ✍ 🎻, 👫 🔢 🐍 &amp; ✔️ 🔗 ⏮️ 🎏 📋 &amp; 🎂 ⚙️ (&amp; ⏮️ 🎏 🏃‍♂ ⚙️, 💾, 🚪, 🇸🇻).
👈 ⛓ 👈 🙆 💲 ✍ 🐍 ⚪️➡️ 🌐 🔢 🔜 `str`, &amp; 🙆 🛠️ 🎏 🆎 ⚖️ 🔬 ✔️ 🔨 📟.
## Pydantic `Settings`
👐, Pydantic 🚚 👑 🚙 🍵 👫 ⚒ 👟 ⚪️➡️ 🌐 🔢 ⏮️ <a href="https://pydantic-docs.helpmanual.io/usage/settings/" class="external-link" target="_blank">Pydantic: ⚒ 🧾</a>.
### ✍ `Settings` 🎚
🗄 `BaseSettings` ⚪️➡️ Pydantic &amp; ✍ 🎧-🎓, 📶 🌅 💖 ⏮️ Pydantic 🏷.
🎏 🌌 ⏮️ Pydantic 🏷, 👆 📣 🎓 🔢 ⏮️ 🆎 ✍, &amp; 🎲 🔢 💲.
👆 💪 ⚙️ 🌐 🎏 🔬 ⚒ &amp; 🧰 👆 ⚙️ Pydantic 🏷, 💖 🎏 📊 🆎 &amp; 🌖 🔬 ⏮️ `Field()`.
```Python hl_lines="2 5-8 11"
{!../../../docs_src/settings/tutorial001.py!}
```
!!! tip
🚥 👆 💚 🕳 ⏩ 📁 &amp; 📋, 🚫 ⚙️ 👉 🖼, ⚙️ 🏁 1️⃣ 🔛.
⤴️, 🕐❔ 👆 ✍ 👐 👈 `Settings` 🎓 (👉 💼, `settings` 🎚), Pydantic 🔜 ✍ 🌐 🔢 💼-😛 🌌,, ↖-💼 🔢 `APP_NAME` 🔜 ✍ 🔢 `app_name`.
⏭ ⚫️ 🔜 🗜 &amp; ✔ 💽. , 🕐❔ 👆 ⚙️ 👈 `settings` 🎚, 👆 🔜 ✔️ 📊 🆎 👆 📣 (✅ `items_per_user` 🔜 `int`).
### ⚙️ `settings`
⤴️ 👆 💪 ⚙️ 🆕 `settings` 🎚 👆 🈸:
```Python hl_lines="18-20"
{!../../../docs_src/settings/tutorial001.py!}
```
### 🏃 💽
⏭, 👆 🔜 🏃 💽 🚶‍♀️ 📳 🌐 🔢, 🖼 👆 💪 ⚒ `ADMIN_EMAIL` &amp; `APP_NAME` ⏮️:
<div class="termy">
```console
$ ADMIN_EMAIL="[email protected]" APP_NAME="ChimichangApp" uvicorn main:app
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
!!! tip
⚒ 💗 🇨🇻 {👁 📋 🎏 👫 ⏮️ 🚀, &amp; 🚮 👫 🌐 ⏭ 📋.
&amp; ⤴️ `admin_email` ⚒ 🔜 ⚒ `"[email protected]"`.
`app_name` 🔜 `"ChimichangApp"`.
&amp; `items_per_user` 🔜 🚧 🚮 🔢 💲 `50`.
## ⚒ ➕1️⃣ 🕹
👆 💪 🚮 👈 ⚒ ➕1️⃣ 🕹 📁 👆 👀 [🦏 🈸 - 💗 📁](../tutorial/bigger-applications.md){.internal-link target=_blank}.
🖼, 👆 💪 ✔️ 📁 `config.py` ⏮️:
```Python
{!../../../docs_src/settings/app01/config.py!}
```
&amp; ⤴️ ⚙️ ⚫️ 📁 `main.py`:
```Python hl_lines="3 11-13"
{!../../../docs_src/settings/app01/main.py!}
```
!!! tip
👆 🔜 💪 📁 `__init__.py` 👆 👀 🔛 [🦏 🈸 - 💗 📁](../tutorial/bigger-applications.md){.internal-link target=_blank}.
## ⚒ 🔗
🍾 ⚫️ 5️⃣📆 ⚠ 🚚 ⚒ ⚪️➡️ 🔗, ↩️ ✔️ 🌐 🎚 ⏮️ `settings` 👈 ⚙️ 🌐.
👉 💪 ✴️ ⚠ ⏮️ 🔬, ⚫️ 📶 ⏩ 🔐 🔗 ⏮️ 👆 👍 🛃 ⚒.
### 📁 📁
👟 ⚪️➡️ ⏮️ 🖼, 👆 `config.py` 📁 💪 👀 💖:
```Python hl_lines="10"
{!../../../docs_src/settings/app02/config.py!}
```
👀 👈 🔜 👥 🚫 ✍ 🔢 👐 `settings = Settings()`.
### 👑 📱 📁
🔜 👥 ✍ 🔗 👈 📨 🆕 `config.Settings()`.
```Python hl_lines="5 11-12"
{!../../../docs_src/settings/app02/main.py!}
```
!!! tip
👥 🔜 🔬 `@lru_cache()` 🍖.
🔜 👆 💪 🤔 `get_settings()` 😐 🔢.
&amp; ⤴️ 👥 💪 🚚 ⚫️ ⚪️➡️ *➡ 🛠️ 🔢* 🔗 &amp; ⚙️ ⚫️ 🙆 👥 💪 ⚫️.
```Python hl_lines="16 18-20"
{!../../../docs_src/settings/app02/main.py!}
```
### ⚒ &amp; 🔬
⤴️ ⚫️ 🔜 📶 ⏩ 🚚 🎏 ⚒ 🎚 ⏮️ 🔬 🏗 🔗 🔐 `get_settings`:
```Python hl_lines="9-10 13 21"
{!../../../docs_src/settings/app02/test_main.py!}
```
🔗 🔐 👥 ⚒ 🆕 💲 `admin_email` 🕐❔ 🏗 🆕 `Settings` 🎚, &amp; ⤴️ 👥 📨 👈 🆕 🎚.
⤴️ 👥 💪 💯 👈 ⚫️ ⚙️.
## 👂 `.env` 📁
🚥 👆 ✔️ 📚 ⚒ 👈 🎲 🔀 📚, 🎲 🎏 🌐, ⚫️ 5️⃣📆 ⚠ 🚮 👫 🔛 📁 &amp; ⤴️ ✍ 👫 ⚪️➡️ ⚫️ 🚥 👫 🌐 🔢.
👉 💡 ⚠ 🥃 👈 ⚫️ ✔️ 📛, 👫 🌐 🔢 🛎 🥉 📁 `.env`, &amp; 📁 🤙 "🇨🇻".
!!! tip
📁 ▶️ ⏮️ ❣ (`.`) 🕵‍♂ 📁 🖥-💖 ⚙️, 💖 💾 &amp; 🇸🇻.
✋️ 🇨🇻 📁 🚫 🤙 ✔️ ✔️ 👈 ☑ 📁.
Pydantic ✔️ 🐕‍🦺 👂 ⚪️➡️ 👉 🆎 📁 ⚙️ 🔢 🗃. 👆 💪 ✍ 🌖 <a href="https://pydantic-docs.helpmanual.io/usage/settings/#dotenv-env-support" class="external-link" target="_blank">Pydantic ⚒: 🇨🇻 (.🇨🇻) 🐕‍🦺</a>.
!!! tip
👉 👷, 👆 💪 `pip install python-dotenv`.
### `.env` 📁
👆 💪 ✔️ `.env` 📁 ⏮️:
```bash
ADMIN_EMAIL="[email protected]"
APP_NAME="ChimichangApp"
```
### ✍ ⚒ ⚪️➡️ `.env`
&amp; ⤴️ ℹ 👆 `config.py` ⏮️:
```Python hl_lines="9-10"
{!../../../docs_src/settings/app03/config.py!}
```
📥 👥 ✍ 🎓 `Config` 🔘 👆 Pydantic `Settings` 🎓, &amp;`env_file` 📁 ⏮️ 🇨🇻 📁 👥 💚 ⚙️.
!!! tip
`Config` 🎓 ⚙️ Pydantic 📳. 👆 💪 ✍ 🌖 <a href="https://pydantic-docs.helpmanual.io/usage/model_config/" class="external-link" target="_blank">Pydantic 🏷 📁</a>
### 🏗 `Settings` 🕴 🕐 ⏮️ `lru_cache`
👂 📁 ⚪️➡️ 💾 🛎 ⚠ (🐌) 🛠️, 👆 🎲 💚 ⚫️ 🕴 🕐 &amp; ⤴️ 🏤-⚙️ 🎏 ⚒ 🎚, ↩️ 👂 ⚫️ 🔠 📨.
✋️ 🔠 🕰 👥:
```Python
Settings()
```
🆕 `Settings` 🎚 🔜 ✍, &amp; 🏗 ⚫️ 🔜 ✍ `.env` 📁 🔄.
🚥 🔗 🔢 💖:
```Python
def get_settings():
return Settings()
```
👥 🔜 ✍ 👈 🎚 🔠 📨, &amp; 👥 🔜 👂 `.env` 📁 🔠 📨. 👶 👶
✋️ 👥 ⚙️ `@lru_cache()` 👨‍🎨 🔛 🔝, `Settings` 🎚 🔜 ✍ 🕴 🕐, 🥇 🕰 ⚫️ 🤙. 👶 👶
```Python hl_lines="1 10"
{!../../../docs_src/settings/app03/main.py!}
```
⤴️ 🙆 🏁 🤙 `get_settings()` 🔗 ⏭ 📨, ↩️ 🛠️ 🔗 📟 `get_settings()` &amp; 🏗 🆕 `Settings` 🎚, ⚫️ 🔜 📨 🎏 🎚 👈 📨 🔛 🥇 🤙, 🔄 &amp; 🔄.
#### `lru_cache` 📡 ℹ
`@lru_cache()` 🔀 🔢 ⚫️ 🎀 📨 🎏 💲 👈 📨 🥇 🕰, ↩️ 💻 ⚫️ 🔄, 🛠️ 📟 🔢 🔠 🕰.
, 🔢 🔛 ⚫️ 🔜 🛠️ 🕐 🔠 🌀 ❌. &amp; ⤴️ 💲 📨 🔠 👈 🌀 ❌ 🔜 ⚙️ 🔄 &amp; 🔄 🕐❔ 🔢 🤙 ⏮️ ⚫️❔ 🎏 🌀 ❌.
🖼, 🚥 👆 ✔️ 🔢:
```Python
@lru_cache()
def say_hi(name: str, salutation: str = "Ms."):
return f"Hello {salutation} {name}"
```
👆 📋 💪 🛠️ 💖 👉:
```mermaid
sequenceDiagram
participant code as Code
participant function as say_hi()
participant execute as Execute function
rect rgba(0, 255, 0, .1)
code ->> function: say_hi(name="Camila")
function ->> execute: execute function code
execute ->> code: return the result
end
rect rgba(0, 255, 255, .1)
code ->> function: say_hi(name="Camila")
function ->> code: return stored result
end
rect rgba(0, 255, 0, .1)
code ->> function: say_hi(name="Rick")
function ->> execute: execute function code
execute ->> code: return the result
end
rect rgba(0, 255, 0, .1)
code ->> function: say_hi(name="Rick", salutation="Mr.")
function ->> execute: execute function code
execute ->> code: return the result
end
rect rgba(0, 255, 255, .1)
code ->> function: say_hi(name="Rick")
function ->> code: return stored result
end
rect rgba(0, 255, 255, .1)
code ->> function: say_hi(name="Camila")
function ->> code: return stored result
end
```
💼 👆 🔗 `get_settings()`, 🔢 🚫 ✊ 🙆 ❌, ⚫️ 🕧 📨 🎏 💲.
👈 🌌, ⚫️ 🎭 🌖 🚥 ⚫️ 🌐 🔢. ✋️ ⚫️ ⚙️ 🔗 🔢, ⤴️ 👥 💪 🔐 ⚫️ 💪 🔬.
`@lru_cache()` 🍕 `functools` ❔ 🍕 🐍 🐩 🗃, 👆 💪 ✍ 🌅 🔃 ⚫️ <a href="https://docs.python.org/3/library/functools.html#functools.lru_cache" class="external-link" target="_blank">🐍 🩺 `@lru_cache()`</a>.
## 🌃
👆 💪 ⚙️ Pydantic ⚒ 🍵 ⚒ ⚖️ 📳 👆 🈸, ⏮️ 🌐 🏋️ Pydantic 🏷.
* ⚙️ 🔗 👆 💪 📉 🔬.
* 👆 💪 ⚙️ `.env` 📁 ⏮️ ⚫️.
* ⚙️ `@lru_cache()` ➡️ 👆 ❎ 👂 🇨🇻 📁 🔄 &amp; 🔄 🔠 📨, ⏪ 🤝 👆 🔐 ⚫️ ⏮️ 🔬.

529
docs/em/docs/advanced/sql-databases-peewee.md

@ -0,0 +1,529 @@
# 🗄 (🔗) 💽 ⏮️ 🏒
!!! warning
🚥 👆 ▶️, 🔰 [🗄 (🔗) 💽](../tutorial/sql-databases.md){.internal-link target=_blank} 👈 ⚙️ 🇸🇲 🔜 🥃.
💭 🆓 🚶 👉.
🚥 👆 ▶️ 🏗 ⚪️➡️ 🖌, 👆 🎲 👻 📆 ⏮️ 🇸🇲 🐜 ([🗄 (🔗) 💽](../tutorial/sql-databases.md){.internal-link target=_blank}), ⚖️ 🙆 🎏 🔁 🐜.
🚥 👆 ⏪ ✔️ 📟 🧢 👈 ⚙️ <a href="https://docs.peewee-orm.com/en/latest/" class="external-link" target="_blank">🏒 🐜</a>, 👆 💪 ✅ 📥 ❔ ⚙️ ⚫️ ⏮️ **FastAPI**.
!!! warning "🐍 3️⃣.7️⃣ ➕ ✔"
👆 🔜 💪 🐍 3️⃣.7️⃣ ⚖️ 🔛 🔒 ⚙️ 🏒 ⏮️ FastAPI.
## 🏒 🔁
🏒 🚫 🔧 🔁 🛠️, ⚖️ ⏮️ 👫 🤯.
🏒 ✔️ 🏋️ 🔑 🔃 🚮 🔢 &amp; 🔃 ❔ ⚫️ 🔜 ⚙️.
🚥 👆 🛠️ 🈸 ⏮️ 🗝 🚫-🔁 🛠️, &amp; 💪 👷 ⏮️ 🌐 🚮 🔢, **⚫️ 💪 👑 🧰**.
✋️ 🚥 👆 💪 🔀 🔢, 🐕‍🦺 🌖 🌘 1️⃣ 🔁 💽, 👷 ⏮️ 🔁 🛠️ (💖 FastAPI), ♒️, 👆 🔜 💪 🚮 🏗 ➕ 📟 🔐 👈 🔢.
👐, ⚫️ 💪 ⚫️, &amp; 📥 👆 🔜 👀 ⚫️❔ ⚫️❔ 📟 👆 ✔️ 🚮 💪 ⚙️ 🏒 ⏮️ FastAPI.
!!! note "📡 ℹ"
👆 💪 ✍ 🌅 🔃 🏒 🧍 🔃 🔁 🐍 <a href="https://docs.peewee-orm.com/en/latest/peewee/database.html#async-with-gevent" class="external-link" target="_blank">🩺</a>, <a href="https://github.com/coleifer/peewee/issues/263#issuecomment-517347032" class="external-link" target="_blank"></a>, <a href="https://github.com/coleifer/peewee/pull/2072#issuecomment-563215132" class="external-link" target="_blank">🇵🇷</a>.
## 🎏 📱
👥 🔜 ✍ 🎏 🈸 🇸🇲 🔰 ([🗄 (🔗) 💽](../tutorial/sql-databases.md){.internal-link target=_blank}).
🌅 📟 🤙 🎏.
, 👥 🔜 🎯 🕴 🔛 🔺.
## 📁 📊
➡️ 💬 👆 ✔️ 📁 📛 `my_super_project` 👈 🔌 🎧-📁 🤙 `sql_app` ⏮️ 📊 💖 👉:
```
.
└── sql_app
├── __init__.py
├── crud.py
├── database.py
├── main.py
└── schemas.py
```
👉 🌖 🎏 📊 👥 ✔️ 🇸🇲 🔰.
🔜 ➡️ 👀 ⚫️❔ 🔠 📁/🕹 🔨.
## ✍ 🏒 🍕
➡️ 🔗 📁 `sql_app/database.py`.
### 🐩 🏒 📟
➡️ 🥇 ✅ 🌐 😐 🏒 📟, ✍ 🏒 💽:
```Python hl_lines="3 5 22"
{!../../../docs_src/sql_databases_peewee/sql_app/database.py!}
```
!!! tip
✔️ 🤯 👈 🚥 👆 💚 ⚙️ 🎏 💽, 💖 ✳, 👆 🚫 🚫 🔀 🎻. 👆 🔜 💪 ⚙️ 🎏 🏒 💽 🎓.
#### 🗒
❌:
```Python
check_same_thread=False
```
🌓 1️⃣ 🇸🇲 🔰:
```Python
connect_args={"check_same_thread": False}
```
...⚫️ 💪 🕴 `SQLite`.
!!! info "📡 ℹ"
⚫️❔ 🎏 📡 ℹ [🗄 (🔗) 💽](../tutorial/sql-databases.md#note){.internal-link target=_blank} ✔.
### ⚒ 🏒 🔁-🔗 `PeeweeConnectionState`
👑 ❔ ⏮️ 🏒 &amp; FastAPI 👈 🏒 ⚓️ 🙇 🔛 <a href="https://docs.python.org/3/library/threading.html#thread-local-data" class="external-link" target="_blank">🐍 `threading.local`</a>, &amp; ⚫️ 🚫 ✔️ 🎯 🌌 🔐 ⚫️ ⚖️ ➡️ 👆 🍵 🔗/🎉 🔗 (🔨 🇸🇲 🔰).
&amp; `threading.local` 🚫 🔗 ⏮️ 🆕 🔁 ⚒ 🏛 🐍.
!!! note "📡 ℹ"
`threading.local` ⚙️ ✔️ "🎱" 🔢 👈 ✔️ 🎏 💲 🔠 🧵.
👉 ⚠ 🗝 🛠️ 🏗 ✔️ 1️⃣ 👁 🧵 📍 📨, 🙅‍♂ 🌖, 🙅‍♂ 🌘.
⚙️ 👉, 🔠 📨 🔜 ✔️ 🚮 👍 💽 🔗/🎉, ❔ ☑ 🏁 🥅.
✋️ FastAPI, ⚙️ 🆕 🔁 ⚒, 💪 🍵 🌅 🌘 1️⃣ 📨 🔛 🎏 🧵. &amp; 🎏 🕰, 👁 📨, ⚫️ 💪 🏃 💗 👜 🎏 🧵 (🧵), ⚓️ 🔛 🚥 👆 ⚙️ `async def` ⚖️ 😐 `def`. 👉 ⚫️❔ 🤝 🌐 🎭 📈 FastAPI.
✋️ 🐍 3️⃣.7️⃣ &amp; 🔛 🚚 🌖 🏧 🎛 `threading.local`, 👈 💪 ⚙️ 🥉 🌐❔ `threading.local` 🔜 ⚙️, ✋️ 🔗 ⏮️ 🆕 🔁 ⚒.
👥 🔜 ⚙️ 👈. ⚫️ 🤙 <a href="https://docs.python.org/3/library/contextvars.html" class="external-link" target="_blank">`contextvars`</a>.
👥 🔜 🔐 🔗 🍕 🏒 👈 ⚙️ `threading.local` &amp; ❎ 👫 ⏮️ `contextvars`, ⏮️ 🔗 ℹ.
👉 5️⃣📆 😑 🍖 🏗 (&amp; ⚫️ 🤙), 👆 🚫 🤙 💪 🍕 🤔 ❔ ⚫️ 👷 ⚙️ ⚫️.
👥 🔜 ✍ `PeeweeConnectionState`:
```Python hl_lines="10-19"
{!../../../docs_src/sql_databases_peewee/sql_app/database.py!}
```
👉 🎓 😖 ⚪️➡️ 🎁 🔗 🎓 ⚙️ 🏒.
⚫️ ✔️ 🌐 ⚛ ⚒ 🏒 ⚙️ `contextvars` ↩️ `threading.local`.
`contextvars` 👷 🍖 🎏 🌘 `threading.local`. ✋️ 🎂 🏒 🔗 📟 🤔 👈 👉 🎓 👷 ⏮️ `threading.local`.
, 👥 💪 ➕ 🎱 ⚒ ⚫️ 👷 🚥 ⚫️ ⚙️ `threading.local`. `__init__`, `__setattr__`, &amp; `__getattr__` 🛠️ 🌐 ✔ 🎱 👉 ⚙️ 🏒 🍵 🤔 👈 ⚫️ 🔜 🔗 ⏮️ FastAPI.
!!! tip
👉 🔜 ⚒ 🏒 🎭 ☑ 🕐❔ ⚙️ ⏮️ FastAPI. 🚫 🎲 📂 ⚖️ 📪 🔗 👈 ➖ ⚙️, 🏗 ❌, ♒️.
✋️ ⚫️ 🚫 🤝 🏒 🔁 💎-🏋️. 👆 🔜 ⚙️ 😐 `def` 🔢 &amp; 🚫 `async def`.
### ⚙️ 🛃 `PeeweeConnectionState` 🎓
🔜, 📁 `._state` 🔗 🔢 🏒 💽 `db` 🎚 ⚙️ 🆕 `PeeweeConnectionState`:
```Python hl_lines="24"
{!../../../docs_src/sql_databases_peewee/sql_app/database.py!}
```
!!! tip
⚒ 💭 👆 📁 `db._state` *⏮️* 🏗 `db`.
!!! tip
👆 🔜 🎏 🙆 🎏 🏒 💽, 🔌 `PostgresqlDatabase`, `MySQLDatabase`, ♒️.
## ✍ 💽 🏷
➡️ 🔜 👀 📁 `sql_app/models.py`.
### ✍ 🏒 🏷 👆 💽
🔜 ✍ 🏒 🏷 (🎓) `User` &amp; `Item`.
👉 🎏 👆 🔜 🚥 👆 ⏩ 🏒 🔰 &amp; ℹ 🏷 ✔️ 🎏 💽 🇸🇲 🔰.
!!! tip
🏒 ⚙️ ⚖ "**🏷**" 🔗 👉 🎓 &amp; 👐 👈 🔗 ⏮️ 💽.
✋️ Pydantic ⚙️ ⚖ "**🏷**" 🔗 🕳 🎏, 💽 🔬, 🛠️, &amp; 🧾 🎓 &amp; 👐.
🗄 `db` ⚪️➡️ `database` (📁 `database.py` ⚪️➡️ 🔛) &amp; ⚙️ ⚫️ 📥.
```Python hl_lines="3 6-12 15-21"
{!../../../docs_src/sql_databases_peewee/sql_app/models.py!}
```
!!! tip
🏒 ✍ 📚 🎱 🔢.
⚫️ 🔜 🔁 🚮 `id` 🔢 🔢 👑 🔑.
⚫️ 🔜 ⚒ 📛 🏓 ⚓️ 🔛 🎓 📛.
`Item`, ⚫️ 🔜 ✍ 🔢 `owner_id` ⏮️ 🔢 🆔 `User`. ✋️ 👥 🚫 📣 ⚫️ 🙆.
## ✍ Pydantic 🏷
🔜 ➡️ ✅ 📁 `sql_app/schemas.py`.
!!! tip
❎ 😨 🖖 🏒 *🏷* &amp; Pydantic *🏷*, 👥 🔜 ✔️ 📁 `models.py` ⏮️ 🏒 🏷, &amp; 📁 `schemas.py` ⏮️ Pydantic 🏷.
👫 Pydantic 🏷 🔬 🌅 ⚖️ 🌘 "🔗" (☑ 📊 💠).
👉 🔜 ℹ 👥 ❎ 😨 ⏪ ⚙️ 👯‍♂️.
### ✍ Pydantic *🏷* / 🔗
✍ 🌐 🎏 Pydantic 🏷 🇸🇲 🔰:
```Python hl_lines="16-18 21-22 25-30 34-35 38-39 42-48"
{!../../../docs_src/sql_databases_peewee/sql_app/schemas.py!}
```
!!! tip
📥 👥 🏗 🏷 ⏮️ `id`.
👥 🚫 🎯 ✔ `id` 🔢 🏒 🏷, ✋️ 🏒 🚮 1️⃣ 🔁.
👥 ❎ 🎱 `owner_id` 🔢 `Item`.
### ✍ `PeeweeGetterDict` Pydantic *🏷* / 🔗
🕐❔ 👆 🔐 💛 🏒 🎚, 💖 `some_user.items`, 🏒 🚫 🚚 `list` `Item`.
⚫️ 🚚 🎁 🛃 🎚 🎓 `ModelSelect`.
⚫️ 💪 ✍ `list` 🚮 🏬 ⏮️ `list(some_user.items)`.
✋️ 🎚 ⚫️ 🚫 `list`. &amp; ⚫️ 🚫 ☑ 🐍 <a href="https://docs.python.org/3/glossary.html#term-generator" class="external-link" target="_blank">🚂</a>. ↩️ 👉, Pydantic 🚫 💭 🔢 ❔ 🗜 ⚫️ `list` Pydantic *🏷* / 🔗.
✋️ ⏮️ ⏬ Pydantic ✔ 🚚 🛃 🎓 👈 😖 ⚪️➡️ `pydantic.utils.GetterDict`, 🚚 🛠️ ⚙️ 🕐❔ ⚙️ `orm_mode = True` 🗃 💲 🐜 🏷 🔢.
👥 🔜 ✍ 🛃 `PeeweeGetterDict` 🎓 &amp; ⚙️ ⚫️ 🌐 🎏 Pydantic *🏷* / 🔗 👈 ⚙️ `orm_mode`:
```Python hl_lines="3 8-13 31 49"
{!../../../docs_src/sql_databases_peewee/sql_app/schemas.py!}
```
📥 👥 ✅ 🚥 🔢 👈 ➖ 🔐 (✅ `.items` `some_user.items`) 👐 `peewee.ModelSelect`.
&amp; 🚥 👈 💼, 📨 `list` ⏮️ ⚫️.
&amp; ⤴️ 👥 ⚙️ ⚫️ Pydantic *🏷* / 🔗 👈 ⚙️ `orm_mode = True`, ⏮️ 📳 🔢 `getter_dict = PeeweeGetterDict`.
!!! tip
👥 🕴 💪 ✍ 1️⃣ `PeeweeGetterDict` 🎓, &amp; 👥 💪 ⚙️ ⚫️ 🌐 Pydantic *🏷* / 🔗.
## 💩 🇨🇻
🔜 ➡️ 👀 📁 `sql_app/crud.py`.
### ✍ 🌐 💩 🇨🇻
✍ 🌐 🎏 💩 🇨🇻 🇸🇲 🔰, 🌐 📟 📶 🎏:
```Python hl_lines="1 4-5 8-9 12-13 16-20 23-24 27-30"
{!../../../docs_src/sql_databases_peewee/sql_app/crud.py!}
```
📤 🔺 ⏮️ 📟 🇸🇲 🔰.
👥 🚫 🚶‍♀️ `db` 🔢 🤭. ↩️ 👥 ⚙️ 🏷 🔗. 👉 ↩️ `db` 🎚 🌐 🎚, 👈 🔌 🌐 🔗 ⚛. 👈 ⚫️❔ 👥 ✔️ 🌐 `contextvars` ℹ 🔛.
🆖, 🕐❔ 🛬 📚 🎚, 💖 `get_users`, 👥 🔗 🤙 `list`, 💖:
```Python
list(models.User.select())
```
👉 🎏 🤔 👈 👥 ✔️ ✍ 🛃 `PeeweeGetterDict`. ✋️ 🛬 🕳 👈 ⏪ `list` ↩️ `peewee.ModelSelect` `response_model` *➡ 🛠️* ⏮️ `List[models.User]` (👈 👥 🔜 👀 ⏪) 🔜 👷 ☑.
## 👑 **FastAPI** 📱
&amp; 🔜 📁 `sql_app/main.py` ➡️ 🛠️ &amp; ⚙️ 🌐 🎏 🍕 👥 ✍ ⏭.
### ✍ 💽 🏓
📶 🙃 🌌 ✍ 💽 🏓:
```Python hl_lines="9-11"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
### ✍ 🔗
✍ 🔗 👈 🔜 🔗 💽 ▶️️ ▶️ 📨 &amp; 🔌 ⚫️ 🔚:
```Python hl_lines="23-29"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
📥 👥 ✔️ 🛁 `yield` ↩️ 👥 🤙 🚫 ⚙️ 💽 🎚 🔗.
⚫️ 🔗 💽 &amp; ♻ 🔗 💽 🔗 🔢 👈 🔬 🔠 📨 (⚙️ `contextvars` 🎱 ⚪️➡️ 🔛).
↩️ 💽 🔗 ⚠ 👤/🅾 🚧, 👉 🔗 ✍ ⏮️ 😐 `def` 🔢.
&amp; ⤴️, 🔠 *➡ 🛠️ 🔢* 👈 💪 🔐 💽 👥 🚮 ⚫️ 🔗.
✋️ 👥 🚫 ⚙️ 💲 👐 👉 🔗 (⚫️ 🤙 🚫 🤝 🙆 💲, ⚫️ ✔️ 🛁 `yield`). , 👥 🚫 🚮 ⚫️ *➡ 🛠️ 🔢* ✋️ *➡ 🛠️ 👨‍🎨* `dependencies` 🔢:
```Python hl_lines="32 40 47 59 65 72"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
### 🔑 🔢 🎧-🔗
🌐 `contextvars` 🍕 👷, 👥 💪 ⚒ 💭 👥 ✔️ 🔬 💲 `ContextVar` 🔠 📨 👈 ⚙️ 💽, &amp; 👈 💲 🔜 ⚙️ 💽 🇵🇸 (🔗, 💵, ♒️) 🎂 📨.
👈, 👥 💪 ✍ ➕1️⃣ `async` 🔗 `reset_db_state()` 👈 ⚙️ 🎧-🔗 `get_db()`. ⚫️ 🔜 ⚒ 💲 🔑 🔢 (⏮️ 🔢 `dict`) 👈 🔜 ⚙️ 💽 🇵🇸 🎂 📨. &amp; ⤴️ 🔗 `get_db()` 🔜 🏪 ⚫️ 💽 🇵🇸 (🔗, 💵, ♒️).
```Python hl_lines="18-20"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
**⏭ 📨**, 👥 🔜 ⏲ 👈 🔑 🔢 🔄 `async` 🔗 `reset_db_state()` &amp; ⤴️ ✍ 🆕 🔗 `get_db()` 🔗, 👈 🆕 📨 🔜 ✔️ 🚮 👍 💽 🇵🇸 (🔗, 💵, ♒️).
!!! tip
FastAPI 🔁 🛠️, 1️⃣ 📨 💪 ▶️ ➖ 🛠️, &amp; ⏭ 🏁, ➕1️⃣ 📨 💪 📨 &amp; ▶️ 🏭 👍, &amp; ⚫️ 🌐 💪 🛠️ 🎏 🧵.
✋️ 🔑 🔢 🤔 👫 🔁 ⚒,, 🏒 💽 🇵🇸 ⚒ `async` 🔗 `reset_db_state()` 🔜 🚧 🚮 👍 💽 🎂 🎂 📨.
&amp; 🎏 🕰, 🎏 🛠️ 📨 🔜 ✔️ 🚮 👍 💽 🇵🇸 👈 🔜 🔬 🎂 📨.
#### 🏒 🗳
🚥 👆 ⚙️ <a href="https://docs.peewee-orm.com/en/latest/peewee/database.html#dynamically-defining-a-database" class="external-link" target="_blank">🏒 🗳</a>, ☑ 💽 `db.obj`.
, 👆 🔜 ⏲ ⚫️ ⏮️:
```Python hl_lines="3-4"
async def reset_db_state():
database.db.obj._state._state.set(db_state_default.copy())
database.db.obj._state.reset()
```
### ✍ 👆 **FastAPI** *➡ 🛠️*
🔜, 😒, 📥 🐩 **FastAPI** *➡ 🛠️* 📟.
```Python hl_lines="32-37 40-43 46-53 56-62 65-68 71-79"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
### 🔃 `def` 🆚 `async def`
🎏 ⏮️ 🇸🇲, 👥 🚫 🔨 🕳 💖:
```Python
user = await models.User.select().first()
```
...✋️ ↩️ 👥 ⚙️:
```Python
user = models.User.select().first()
```
, 🔄, 👥 🔜 📣 *➡ 🛠️ 🔢* &amp; 🔗 🍵 `async def`, ⏮️ 😐 `def`,:
```Python hl_lines="2"
# Something goes here
def read_users(skip: int = 0, limit: int = 100):
# Something goes here
```
## 🔬 🏒 ⏮️ 🔁
👉 🖼 🔌 ➕ *➡ 🛠️* 👈 🔬 📏 🏭 📨 ⏮️ `time.sleep(sleep_time)`.
⚫️ 🔜 ✔️ 💽 🔗 📂 ▶️ &amp; 🔜 ⌛ 🥈 ⏭ 🙇 🔙. &amp; 🔠 🆕 📨 🔜 ⌛ 🕐 🥈 🌘.
👉 🔜 💪 ➡️ 👆 💯 👈 👆 📱 ⏮️ 🏒 &amp; FastAPI 🎭 ☑ ⏮️ 🌐 💩 🔃 🧵.
🚥 👆 💚 ✅ ❔ 🏒 🔜 💔 👆 📱 🚥 ⚙️ 🍵 🛠️, 🚶 `sql_app/database.py` 📁 &amp; 🏤 ⏸:
```Python
# db._state = PeeweeConnectionState()
```
&amp; 📁 `sql_app/main.py` 📁, 🏤 💪 `async` 🔗 `reset_db_state()` &amp; ❎ ⚫️ ⏮️ `pass`:
```Python
async def reset_db_state():
# database.db._state._state.set(db_state_default.copy())
# database.db._state.reset()
pass
```
⤴️ 🏃 👆 📱 ⏮️ Uvicorn:
<div class="termy">
```console
$ uvicorn sql_app.main:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
📂 👆 🖥 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a> &amp; ✍ 👩‍❤‍👨 👩‍💻.
⤴️ 📂 1️⃣0️⃣ 📑 <a href="http://127.0.0.1:8000/docs#/default/read_slow_users_slowusers__get" class="external-link" target="_blank">http://127.0.0.1:8000/docs#/default/read_🐌_👩‍💻_slowusers_ = </a> 🎏 🕰.
🚶 *➡ 🛠️* "🤚 `/slowusers/`" 🌐 📑. ⚙️ "🔄 ⚫️ 👅" 🔼 &amp; 🛠️ 📨 🔠 📑, 1️⃣ ▶️️ ⏮️ 🎏.
📑 🔜 ⌛ 🍖 &amp; ⤴️ 👫 🔜 🎦 `Internal Server Error`.
### ⚫️❔ 🔨
🥇 📑 🔜 ⚒ 👆 📱 ✍ 🔗 💽 &amp; ⌛ 🥈 ⏭ 🙇 🔙 &amp; 📪 💽 🔗.
⤴️, 📨 ⏭ 📑, 👆 📱 🔜 ⌛ 🕐 🥈 🌘, &amp; 🔛.
👉 ⛓ 👈 ⚫️ 🔜 🔚 🆙 🏁 🏁 📑' 📨 ⏪ 🌘 ⏮️ 🕐.
⤴️ 1️⃣ 🏁 📨 👈 ⌛ 🌘 🥈 🔜 🔄 📂 💽 🔗, ✋️ 1️⃣ 📚 ⏮️ 📨 🎏 📑 🔜 🎲 🍵 🎏 🧵 🥇 🕐, ⚫️ 🔜 ✔️ 🎏 💽 🔗 👈 ⏪ 📂, &amp; 🏒 🔜 🚮 ❌ &amp; 👆 🔜 👀 ⚫️ 📶, &amp; 📨 🔜 ✔️ `Internal Server Error`.
👉 🔜 🎲 🔨 🌅 🌘 1️⃣ 📚 📑.
🚥 👆 ✔️ 💗 👩‍💻 💬 👆 📱 ⚫️❔ 🎏 🕰, 👉 ⚫️❔ 💪 🔨.
&amp; 👆 📱 ▶️ 🍵 🌅 &amp; 🌖 👩‍💻 🎏 🕰, ⌛ 🕰 👁 📨 💪 📏 &amp; 📏 ⏲ ❌.
### 🔧 🏒 ⏮️ FastAPI
🔜 🚶 🔙 📁 `sql_app/database.py`, &amp; ✍ ⏸:
```Python
db._state = PeeweeConnectionState()
```
&amp; 📁 `sql_app/main.py` 📁, ✍ 💪 `async` 🔗 `reset_db_state()`:
```Python
async def reset_db_state():
database.db._state._state.set(db_state_default.copy())
database.db._state.reset()
```
❎ 👆 🏃‍♂ 📱 &amp; ▶️ ⚫️ 🔄.
🔁 🎏 🛠️ ⏮️ 1️⃣0️⃣ 📑. 👉 🕰 🌐 👫 🔜 ⌛ &amp; 👆 🔜 🤚 🌐 🏁 🍵 ❌.
...👆 🔧 ⚫️ ❗
## 📄 🌐 📁
💭 👆 🔜 ✔️ 📁 📛 `my_super_project` (⚖️ 👐 👆 💚) 👈 🔌 🎧-📁 🤙 `sql_app`.
`sql_app` 🔜 ✔️ 📄 📁:
* `sql_app/__init__.py`: 🛁 📁.
* `sql_app/database.py`:
```Python
{!../../../docs_src/sql_databases_peewee/sql_app/database.py!}
```
* `sql_app/models.py`:
```Python
{!../../../docs_src/sql_databases_peewee/sql_app/models.py!}
```
* `sql_app/schemas.py`:
```Python
{!../../../docs_src/sql_databases_peewee/sql_app/schemas.py!}
```
* `sql_app/crud.py`:
```Python
{!../../../docs_src/sql_databases_peewee/sql_app/crud.py!}
```
* `sql_app/main.py`:
```Python
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
## 📡 ℹ
!!! warning
👉 📶 📡 ℹ 👈 👆 🎲 🚫 💪.
### ⚠
🏒 ⚙️ <a href="https://docs.python.org/3/library/threading.html#thread-local-data" class="external-link" target="_blank">`threading.local`</a> 🔢 🏪 ⚫️ 💽 "🇵🇸" 💽 (🔗, 💵, ♒️).
`threading.local` ✍ 💲 🌟 ⏮️ 🧵, ✋️ 🔁 🛠️ 🔜 🏃 🌐 📟 (✅ 🔠 📨) 🎏 🧵, &amp; 🎲 🚫 ✔.
🔛 🔝 👈, 🔁 🛠️ 💪 🏃 🔁 📟 🧵 (⚙️ `asyncio.run_in_executor`), ✋️ 🔗 🎏 📨.
👉 ⛓ 👈, ⏮️ 🏒 ⏮️ 🛠️, 💗 📋 💪 ⚙️ 🎏 `threading.local` 🔢 &amp; 🔚 🆙 🤝 🎏 🔗 &amp; 💽 (👈 👫 🚫🔜 🚫), &amp; 🎏 🕰, 🚥 👫 🛠️ 🔁 👤/🅾-🚧 📟 🧵 (⏮️ 😐 `def` 🔢 FastAPI, *➡ 🛠️* &amp; 🔗), 👈 📟 🏆 🚫 ✔️ 🔐 💽 🇵🇸 🔢, ⏪ ⚫️ 🍕 🎏 📨 &amp; ⚫️ 🔜 💪 🤚 🔐 🎏 💽 🇵🇸.
### 🔑 🔢
🐍 3️⃣.7️⃣ ✔️ <a href="https://docs.python.org/3/library/contextvars.html" class="external-link" target="_blank">`contextvars`</a> 👈 💪 ✍ 🇧🇿 🔢 📶 🎏 `threading.local`, ✋️ 🔗 👫 🔁 ⚒.
📤 📚 👜 ✔️ 🤯.
`ContextVar` ✔️ ✍ 🔝 🕹, 💖:
```Python
some_var = ContextVar("some_var", default="default value")
```
⚒ 💲 ⚙️ ⏮️ "🔑" (✅ ⏮️ 📨) ⚙️:
```Python
some_var.set("new value")
```
🤚 💲 🙆 🔘 🔑 (✅ 🙆 🍕 🚚 ⏮️ 📨) ⚙️:
```Python
some_var.get()
```
### ⚒ 🔑 🔢 `async` 🔗 `reset_db_state()`
🚥 🍕 🔁 📟 ⚒ 💲 ⏮️ `some_var.set("updated in function")` (✅ 💖 `async` 🔗), 🎂 📟 ⚫️ &amp; 📟 👈 🚶 ⏮️ (✅ 📟 🔘 `async` 🔢 🤙 ⏮️ `await`) 🔜 👀 👈 🆕 💲.
, 👆 💼, 🚥 👥 ⚒ 🏒 🇵🇸 🔢 (⏮️ 🔢 `dict`) `async` 🔗, 🌐 🎂 🔗 📟 👆 📱 🔜 👀 👉 💲 &amp; 🔜 💪 ♻ ⚫️ 🎂 📨.
&amp; 🔑 🔢 🔜 ⚒ 🔄 ⏭ 📨, 🚥 👫 🛠️.
### ⚒ 💽 🇵🇸 🔗 `get_db()`
`get_db()` 😐 `def` 🔢, **FastAPI** 🔜 ⚒ ⚫️ 🏃 🧵, ⏮️ *📁* "🔑", 🧑‍🤝‍🧑 🎏 💲 🔑 🔢 ( `dict` ⏮️ ⏲ 💽 🇵🇸). ⤴️ ⚫️ 💪 🚮 💽 🇵🇸 👈 `dict`, 💖 🔗, ♒️.
✋️ 🚥 💲 🔑 🔢 (🔢 `dict`) ⚒ 👈 😐 `def` 🔢, ⚫️ 🔜 ✍ 🆕 💲 👈 🔜 🚧 🕴 👈 🧵 🧵, &amp; 🎂 📟 (💖 *➡ 🛠️ 🔢*) 🚫🔜 ✔️ 🔐 ⚫️. `get_db()` 👥 💪 🕴 ⚒ 💲 `dict`, ✋️ 🚫 🎂 `dict` ⚫️.
, 👥 💪 ✔️ `async` 🔗 `reset_db_state()``dict` 🔑 🔢. 👈 🌌, 🌐 📟 ✔️ 🔐 🎏 `dict` 💽 🇵🇸 👁 📨.
### 🔗 &amp; 🔌 🔗 `get_db()`
⤴️ ⏭ ❔ 🔜, ⚫️❔ 🚫 🔗 &amp; 🔌 💽 `async` 🔗 ⚫️, ↩️ `get_db()`
`async` 🔗 ✔️ `async` 🔑 🔢 🛡 🎂 📨, ✋️ 🏗 &amp; 📪 💽 🔗 ⚠ 🚧, ⚫️ 💪 📉 🎭 🚥 ⚫️ 📤.
👥 💪 😐 `def` 🔗 `get_db()`.

73
docs/em/docs/advanced/sub-applications.md

@ -0,0 +1,73 @@
# 🎧 🈸 - 🗻
🚥 👆 💪 ✔️ 2️⃣ 🔬 FastAPI 🈸, ⏮️ 👫 👍 🔬 🗄 &amp; 👫 👍 🩺 ⚜, 👆 💪 ✔️ 👑 📱 &amp; "🗻" 1️⃣ (⚖️ 🌅) 🎧-🈸(Ⓜ).
## 🗜 **FastAPI** 🈸
"🗜" ⛓ ❎ 🍕 "🔬" 🈸 🎯 ➡, 👈 ⤴️ ✊ 💅 🚚 🌐 🔽 👈 ➡, ⏮️ _➡ 🛠️_ 📣 👈 🎧-🈸.
### 🔝-🎚 🈸
🥇, ✍ 👑, 🔝-🎚, **FastAPI** 🈸, &amp; 🚮 *➡ 🛠️*:
```Python hl_lines="3 6-8"
{!../../../docs_src/sub_applications/tutorial001.py!}
```
### 🎧-🈸
⤴️, ✍ 👆 🎧-🈸, &amp; 🚮 *➡ 🛠️*.
👉 🎧-🈸 ➕1️⃣ 🐩 FastAPI 🈸, ✋️ 👉 1️⃣ 👈 🔜 "🗻":
```Python hl_lines="11 14-16"
{!../../../docs_src/sub_applications/tutorial001.py!}
```
### 🗻 🎧-🈸
👆 🔝-🎚 🈸, `app`, 🗻 🎧-🈸, `subapi`.
👉 💼, ⚫️ 🔜 📌 ➡ `/subapi`:
```Python hl_lines="11 19"
{!../../../docs_src/sub_applications/tutorial001.py!}
```
### ✅ 🏧 🛠️ 🩺
🔜, 🏃 `uvicorn` ⏮️ 👑 📱, 🚥 👆 📁 `main.py`, ⚫️ 🔜:
<div class="termy">
```console
$ uvicorn main:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
&amp; 📂 🩺 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
👆 🔜 👀 🏧 🛠️ 🩺 👑 📱, 🔌 🕴 🚮 👍 _➡ 🛠️_:
<img src="/img/tutorial/sub-applications/image01.png">
&amp; ⤴️, 📂 🩺 🎧-🈸, <a href="http://127.0.0.1:8000/subapi/docs" class="external-link" target="_blank">http://127.0.0.1:8000/subapi/docs</a>.
👆 🔜 👀 🏧 🛠️ 🩺 🎧-🈸, ✅ 🕴 🚮 👍 _➡ 🛠️_, 🌐 🔽 ☑ 🎧-➡ 🔡 `/subapi`:
<img src="/img/tutorial/sub-applications/image02.png">
🚥 👆 🔄 🔗 ⏮️ 🙆 2️⃣ 👩‍💻 🔢, 👫 🔜 👷 ☑, ↩️ 🖥 🔜 💪 💬 🔠 🎯 📱 ⚖️ 🎧-📱.
### 📡 ℹ: `root_path`
🕐❔ 👆 🗻 🎧-🈸 🔬 🔛, FastAPI 🔜 ✊ 💅 🔗 🗻 ➡ 🎧-🈸 ⚙️ 🛠️ ⚪️➡️ 🔫 🔧 🤙 `root_path`.
👈 🌌, 🎧-🈸 🔜 💭 ⚙️ 👈 ➡ 🔡 🩺 🎚.
&amp; 🎧-🈸 💪 ✔️ 🚮 👍 📌 🎧-🈸 &amp; 🌐 🔜 👷 ☑, ↩️ FastAPI 🍵 🌐 👉 `root_path`Ⓜ 🔁.
👆 🔜 💡 🌅 🔃 `root_path` &amp; ❔ ⚙️ ⚫️ 🎯 📄 🔃 [⛅ 🗳](./behind-a-proxy.md){.internal-link target=_blank}.

77
docs/em/docs/advanced/templates.md

@ -0,0 +1,77 @@
# 📄
👆 💪 ⚙️ 🙆 📄 🚒 👆 💚 ⏮️ **FastAPI**.
⚠ ⚒ Jinja2️⃣, 🎏 1️⃣ ⚙️ 🏺 &amp; 🎏 🧰.
📤 🚙 🔗 ⚫️ 💪 👈 👆 💪 ⚙️ 🔗 👆 **FastAPI** 🈸 (🚚 💃).
## ❎ 🔗
`jinja2`:
<div class="termy">
```console
$ pip install jinja2
---> 100%
```
</div>
## ⚙️ `Jinja2Templates`
* 🗄 `Jinja2Templates`.
* ✍ `templates` 🎚 👈 👆 💪 🏤-⚙️ ⏪.
* 📣 `Request` 🔢 *➡ 🛠️* 👈 🔜 📨 📄.
* ⚙️ `templates` 👆 ✍ ✍ &amp; 📨 `TemplateResponse`, 🚶‍♀️ `request` 1️⃣ 🔑-💲 👫 Jinja2️⃣ "🔑".
```Python hl_lines="4 11 15-16"
{!../../../docs_src/templates/tutorial001.py!}
```
!!! note
👀 👈 👆 ✔️ 🚶‍♀️ `request` 🍕 🔑-💲 👫 🔑 Jinja2️⃣. , 👆 ✔️ 📣 ⚫️ 👆 *➡ 🛠️*.
!!! tip
📣 `response_class=HTMLResponse` 🩺 🎚 🔜 💪 💭 👈 📨 🔜 🕸.
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.templating import Jinja2Templates`.
**FastAPI** 🚚 🎏 `starlette.templating` `fastapi.templating` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 📨 👟 🔗 ⚪️➡️ 💃. 🎏 ⏮️ `Request` &amp; `StaticFiles`.
## ✍ 📄
⤴️ 👆 💪 ✍ 📄 `templates/item.html` ⏮️:
```jinja hl_lines="7"
{!../../../docs_src/templates/templates/item.html!}
```
⚫️ 🔜 🎦 `id` ✊ ⚪️➡️ "🔑" `dict` 👆 🚶‍♀️:
```Python
{"request": request, "id": id}
```
## 📄 &amp; 🎻 📁
&amp; 👆 💪 ⚙️ `url_for()` 🔘 📄, &amp; ⚙️ ⚫️, 🖼, ⏮️ `StaticFiles` 👆 📌.
```jinja hl_lines="4"
{!../../../docs_src/templates/templates/item.html!}
```
👉 🖼, ⚫️ 🔜 🔗 🎚 📁 `static/styles.css` ⏮️:
```CSS hl_lines="4"
{!../../../docs_src/templates/static/styles.css!}
```
&amp; ↩️ 👆 ⚙️ `StaticFiles`, 👈 🎚 📁 🔜 🍦 🔁 👆 **FastAPI** 🈸 📛 `/static/styles.css`.
## 🌅 ℹ
🌅 ℹ, 🔌 ❔ 💯 📄, ✅ <a href="https://www.starlette.io/templates/" class="external-link" target="_blank">💃 🩺 🔛 📄</a>.

95
docs/em/docs/advanced/testing-database.md

@ -0,0 +1,95 @@
# 🔬 💽
👆 💪 ⚙️ 🎏 🔗 🔐 ⚪️➡️ [🔬 🔗 ⏮️ 🔐](testing-dependencies.md){.internal-link target=_blank} 📉 💽 🔬.
👆 💪 💚 ⚒ 🆙 🎏 💽 🔬, 💾 💽 ⏮️ 💯, 🏤-🥧 ⚫️ ⏮️ 🔬 💽, ♒️.
👑 💭 ⚫️❔ 🎏 👆 👀 👈 ⏮️ 📃.
## 🚮 💯 🗄 📱
➡️ ℹ 🖼 ⚪️➡️ [🗄 (🔗) 💽](../tutorial/sql-databases.md){.internal-link target=_blank} ⚙️ 🔬 💽.
🌐 📱 📟 🎏, 👆 💪 🚶 🔙 👈 📃 ✅ ❔ ⚫️.
🕴 🔀 📥 🆕 🔬 📁.
👆 😐 🔗 `get_db()` 🔜 📨 💽 🎉.
💯, 👆 💪 ⚙️ 🔗 🔐 📨 👆 *🛃* 💽 🎉 ↩️ 1️⃣ 👈 🔜 ⚙️ 🛎.
👉 🖼 👥 🔜 ✍ 🍕 💽 🕴 💯.
## 📁 📊
👥 ✍ 🆕 📁 `sql_app/tests/test_sql_app.py`.
🆕 📁 📊 👀 💖:
``` hl_lines="9-11"
.
└── sql_app
├── __init__.py
├── crud.py
├── database.py
├── main.py
├── models.py
├── schemas.py
└── tests
├── __init__.py
└── test_sql_app.py
```
## ✍ 🆕 💽 🎉
🥇, 👥 ✍ 🆕 💽 🎉 ⏮️ 🆕 💽.
💯 👥 🔜 ⚙️ 📁 `test.db` ↩️ `sql_app.db`.
✋️ 🎂 🎉 📟 🌅 ⚖️ 🌘 🎏, 👥 📁 ⚫️.
```Python hl_lines="8-13"
{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
```
!!! tip
👆 💪 📉 ❎ 👈 📟 🚮 ⚫️ 🔢 &amp; ⚙️ ⚫️ ⚪️➡️ 👯‍♂️ `database.py` &amp; `tests/test_sql_app.py`.
🦁 &amp; 🎯 🔛 🎯 🔬 📟, 👥 🖨 ⚫️.
## ✍ 💽
↩️ 🔜 👥 🔜 ⚙️ 🆕 💽 🆕 📁, 👥 💪 ⚒ 💭 👥 ✍ 💽 ⏮️:
```Python
Base.metadata.create_all(bind=engine)
```
👈 🛎 🤙 `main.py`, ✋️ ⏸ `main.py` ⚙️ 💽 📁 `sql_app.db`, &amp; 👥 💪 ⚒ 💭 👥 ✍ `test.db` 💯.
👥 🚮 👈 ⏸ 📥, ⏮️ 🆕 📁.
```Python hl_lines="16"
{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
```
## 🔗 🔐
🔜 👥 ✍ 🔗 🔐 &amp; 🚮 ⚫️ 🔐 👆 📱.
```Python hl_lines="19-24 27"
{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
```
!!! tip
📟 `override_get_db()` 🌖 ⚫️❔ 🎏 `get_db()`, ✋️ `override_get_db()` 👥 ⚙️ `TestingSessionLocal` 🔬 💽 ↩️.
## 💯 📱
⤴️ 👥 💪 💯 📱 🛎.
```Python hl_lines="32-47"
{!../../../docs_src/sql_databases/sql_app/tests/test_sql_app.py!}
```
&amp; 🌐 🛠️ 👥 ⚒ 💽 ⏮️ 💯 🔜 `test.db` 💽 ↩️ 👑 `sql_app.db`.

49
docs/em/docs/advanced/testing-dependencies.md

@ -0,0 +1,49 @@
# 🔬 🔗 ⏮️ 🔐
## 🔑 🔗 ⏮️ 🔬
📤 😐 🌐❔ 👆 💪 💚 🔐 🔗 ⏮️ 🔬.
👆 🚫 💚 ⏮️ 🔗 🏃 (🚫 🙆 🎧-🔗 ⚫️ 💪 ✔️).
↩️, 👆 💚 🚚 🎏 🔗 👈 🔜 ⚙️ 🕴 ⏮️ 💯 (🎲 🕴 🎯 💯), &amp; 🔜 🚚 💲 👈 💪 ⚙️ 🌐❔ 💲 ⏮️ 🔗 ⚙️.
### ⚙️ 💼: 🔢 🐕‍🦺
🖼 💪 👈 👆 ✔️ 🔢 🤝 🐕‍🦺 👈 👆 💪 🤙.
👆 📨 ⚫️ 🤝 &amp; ⚫️ 📨 🔓 👩‍💻.
👉 🐕‍🦺 5️⃣📆 🔌 👆 📍 📨, &amp; 🤙 ⚫️ 💪 ✊ ➕ 🕰 🌘 🚥 👆 ✔️ 🔧 🎁 👩‍💻 💯.
👆 🎲 💚 💯 🔢 🐕‍🦺 🕐, ✋️ 🚫 🎯 🤙 ⚫️ 🔠 💯 👈 🏃.
👉 💼, 👆 💪 🔐 🔗 👈 🤙 👈 🐕‍🦺, &amp; ⚙️ 🛃 🔗 👈 📨 🎁 👩‍💻, 🕴 👆 💯.
### ⚙️ `app.dependency_overrides` 🔢
👫 💼, 👆 **FastAPI** 🈸 ✔️ 🔢 `app.dependency_overrides`, ⚫️ 🙅 `dict`.
🔐 🔗 🔬, 👆 🚮 🔑 ⏮️ 🔗 (🔢), &amp; 💲, 👆 🔗 🔐 (➕1️⃣ 🔢).
&amp; ⤴️ **FastAPI** 🔜 🤙 👈 🔐 ↩️ ⏮️ 🔗.
```Python hl_lines="28-29 32"
{!../../../docs_src/dependency_testing/tutorial001.py!}
```
!!! tip
👆 💪 ⚒ 🔗 🔐 🔗 ⚙️ 🙆 👆 **FastAPI** 🈸.
⏮️ 🔗 💪 ⚙️ *➡ 🛠️ 🔢*, *➡ 🛠️ 👨‍🎨* (🕐❔ 👆 🚫 ⚙️ 📨 💲), `.include_router()` 🤙, ♒️.
FastAPI 🔜 💪 🔐 ⚫️.
⤴️ 👆 💪 ⏲ 👆 🔐 (❎ 👫) ⚒ `app.dependency_overrides` 🛁 `dict`:
```Python
app.dependency_overrides = {}
```
!!! tip
🚥 👆 💚 🔐 🔗 🕴 ⏮️ 💯, 👆 💪 ⚒ 🔐 ▶️ 💯 (🔘 💯 🔢) &amp; ⏲ ⚫️ 🔚 (🔚 💯 🔢).

7
docs/em/docs/advanced/testing-events.md

@ -0,0 +1,7 @@
# 🔬 🎉: 🕴 - 🤫
🕐❔ 👆 💪 👆 🎉 🐕‍🦺 (`startup` &amp; `shutdown`) 🏃 👆 💯, 👆 💪 ⚙️ `TestClient` ⏮️ `with` 📄:
```Python hl_lines="9-12 20-24"
{!../../../docs_src/app_testing/tutorial003.py!}
```

12
docs/em/docs/advanced/testing-websockets.md

@ -0,0 +1,12 @@
# 🔬 *️⃣
👆 💪 ⚙️ 🎏 `TestClient` 💯*️⃣.
👉, 👆 ⚙️ `TestClient` `with` 📄, 🔗*️⃣:
```Python hl_lines="27-31"
{!../../../docs_src/app_testing/tutorial002.py!}
```
!!! note
🌅 ℹ, ✅ 💃 🧾 <a href="https://www.starlette.io/testclient/#testing-websocket-sessions" class="external-link" target="_blank">🔬 *️⃣ </a>.

52
docs/em/docs/advanced/using-request-directly.md

@ -0,0 +1,52 @@
# ⚙️ 📨 🔗
🆙 🔜, 👆 ✔️ 📣 🍕 📨 👈 👆 💪 ⏮️ 👫 🆎.
✊ 📊 ⚪️➡️:
* ➡ 🔢.
* 🎚.
* 🍪.
* ♒️.
&amp; 🔨, **FastAPI** ⚖ 👈 💽, 🏭 ⚫️ &amp; 🏭 🧾 👆 🛠️ 🔁.
✋️ 📤 ⚠ 🌐❔ 👆 💪 💪 🔐 `Request` 🎚 🔗.
## ℹ 🔃 `Request` 🎚
**FastAPI** 🤙 **💃** 🔘, ⏮️ 🧽 📚 🧰 🔛 🔝, 👆 💪 ⚙️ 💃 <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">`Request`</a> 🎚 🔗 🕐❔ 👆 💪.
⚫️ 🔜 ⛓ 👈 🚥 👆 🤚 📊 ⚪️➡️ `Request` 🎚 🔗 (🖼, ✍ 💪) ⚫️ 🏆 🚫 ✔, 🗜 ⚖️ 📄 (⏮️ 🗄, 🏧 🛠️ 👩‍💻 🔢) FastAPI.
👐 🙆 🎏 🔢 📣 🛎 (🖼, 💪 ⏮️ Pydantic 🏷) 🔜 ✔, 🗜, ✍, ♒️.
✋️ 📤 🎯 💼 🌐❔ ⚫️ ⚠ 🤚 `Request` 🎚.
## ⚙️ `Request` 🎚 🔗
➡️ 🌈 👆 💚 🤚 👩‍💻 📢 📢/🦠 🔘 👆 *➡ 🛠️ 🔢*.
👈 👆 💪 🔐 📨 🔗.
```Python hl_lines="1 7-8"
{!../../../docs_src/using_request_directly/tutorial001.py!}
```
📣 *➡ 🛠️ 🔢* 🔢 ⏮️ 🆎 ➖ `Request` **FastAPI** 🔜 💭 🚶‍♀️ `Request` 👈 🔢.
!!! tip
🗒 👈 👉 💼, 👥 📣 ➡ 🔢 ⤴️ 📨 🔢.
, ➡ 🔢 🔜 ⚗, ✔, 🗜 ✔ 🆎 &amp; ✍ ⏮️ 🗄.
🎏 🌌, 👆 💪 📣 🙆 🎏 🔢 🛎, &amp; ➡, 🤚 `Request` 💁‍♂️.
## `Request` 🧾
👆 💪 ✍ 🌅 ℹ 🔃 <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">`Request` 🎚 🛂 💃 🧾 🕸</a>.
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.requests import Request`.
**FastAPI** 🚚 ⚫️ 🔗 🏪 👆, 👩‍💻. ✋️ ⚫️ 👟 🔗 ⚪️➡️ 💃.

184
docs/em/docs/advanced/websockets.md

@ -0,0 +1,184 @@
# *️⃣
👆 💪 ⚙️ <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API" class="external-link" target="_blank"> *️⃣ </a> ⏮️ **FastAPI**.
## ❎ `WebSockets`
🥇 👆 💪 ❎ `WebSockets`:
<div class="termy">
```console
$ pip install websockets
---> 100%
```
</div>
## *️⃣ 👩‍💻
### 🏭
👆 🏭 ⚙️, 👆 🎲 ✔️ 🕸 ✍ ⏮️ 🏛 🛠️ 💖 😥, Vue.js ⚖️ 📐.
&amp; 🔗 ⚙️ *️⃣ ⏮️ 👆 👩‍💻 👆 🔜 🎲 ⚙️ 👆 🕸 🚙.
⚖️ 👆 💪 ✔️ 🇦🇸 📱 🈸 👈 🔗 ⏮️ 👆 *️⃣ 👩‍💻 🔗, 🇦🇸 📟.
⚖️ 👆 5️⃣📆 ✔️ 🙆 🎏 🌌 🔗 ⏮️ *️⃣ 🔗.
---
✋️ 👉 🖼, 👥 🔜 ⚙️ 📶 🙅 🕸 📄 ⏮️ 🕸, 🌐 🔘 📏 🎻.
👉, ↗️, 🚫 ⚖ &amp; 👆 🚫🔜 ⚙️ ⚫️ 🏭.
🏭 👆 🔜 ✔️ 1️⃣ 🎛 🔛.
✋️ ⚫️ 🙅 🌌 🎯 🔛 💽-🚄 *️⃣ &amp; ✔️ 👷 🖼:
```Python hl_lines="2 6-38 41-43"
{!../../../docs_src/websockets/tutorial001.py!}
```
## ✍ `websocket`
👆 **FastAPI** 🈸, ✍ `websocket`:
```Python hl_lines="1 46-47"
{!../../../docs_src/websockets/tutorial001.py!}
```
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.websockets import WebSocket`.
**FastAPI** 🚚 🎏 `WebSocket` 🔗 🏪 👆, 👩‍💻. ✋️ ⚫️ 👟 🔗 ⚪️➡️ 💃.
## ⌛ 📧 &amp; 📨 📧
👆 *️⃣ 🛣 👆 💪 `await` 📧 &amp; 📨 📧.
```Python hl_lines="48-52"
{!../../../docs_src/websockets/tutorial001.py!}
```
👆 💪 📨 &amp; 📨 💱, ✍, &amp; 🎻 💽.
## 🔄 ⚫️
🚥 👆 📁 📛 `main.py`, 🏃 👆 🈸 ⏮️:
<div class="termy">
```console
$ uvicorn main:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
📂 👆 🖥 <a href="http://127.0.0.1:8000" class="external-link" target="_blank">http://127.0.0.1:8000</a>.
👆 🔜 👀 🙅 📃 💖:
<img src="/img/tutorial/websockets/image01.png">
👆 💪 🆎 📧 🔢 📦, &amp; 📨 👫:
<img src="/img/tutorial/websockets/image02.png">
&amp; 👆 **FastAPI** 🈸 ⏮️ *️⃣ 🔜 📨 🔙:
<img src="/img/tutorial/websockets/image03.png">
👆 💪 📨 (&amp; 📨) 📚 📧:
<img src="/img/tutorial/websockets/image04.png">
&amp; 🌐 👫 🔜 ⚙️ 🎏 *️⃣ 🔗.
## ⚙️ `Depends` &amp; 🎏
*️⃣ 🔗 👆 💪 🗄 ⚪️➡️ `fastapi` &amp; ⚙️:
* `Depends`
* `Security`
* `Cookie`
* `Header`
* `Path`
* `Query`
👫 👷 🎏 🌌 🎏 FastAPI 🔗/*➡ 🛠️*:
```Python hl_lines="66-77 76-91"
{!../../../docs_src/websockets/tutorial002.py!}
```
!!! info
👉 *️⃣ ⚫️ 🚫 🤙 ⚒ 🔑 🤚 `HTTPException`, ↩️ 👥 🤚 `WebSocketException`.
👆 💪 ⚙️ 📪 📟 ⚪️➡️ <a href="https://tools.ietf.org/html/rfc6455#section-7.4.1" class="external-link" target="_blank">☑ 📟 🔬 🔧</a>.
### 🔄 *️⃣ ⏮️ 🔗
🚥 👆 📁 📛 `main.py`, 🏃 👆 🈸 ⏮️:
<div class="termy">
```console
$ uvicorn main:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
📂 👆 🖥 <a href="http://127.0.0.1:8000" class="external-link" target="_blank">http://127.0.0.1:8000</a>.
📤 👆 💪 ⚒:
* "🏬 🆔", ⚙️ ➡.
* "🤝" ⚙️ 🔢 🔢.
!!! tip
👀 👈 🔢 `token` 🔜 🍵 🔗.
⏮️ 👈 👆 💪 🔗 *️⃣ &amp; ⤴️ 📨 &amp; 📨 📧:
<img src="/img/tutorial/websockets/image05.png">
## 🚚 🔀 &amp; 💗 👩‍💻
🕐❔ *️⃣ 🔗 📪, `await websocket.receive_text()` 🔜 🤚 `WebSocketDisconnect` ⚠, ❔ 👆 💪 ⤴️ ✊ &amp; 🍵 💖 👉 🖼.
```Python hl_lines="81-83"
{!../../../docs_src/websockets/tutorial003.py!}
```
🔄 ⚫️ 👅:
* 📂 📱 ⏮️ 📚 🖥 📑.
* ✍ 📧 ⚪️➡️ 👫.
* ⤴️ 🔐 1️⃣ 📑.
👈 🔜 🤚 `WebSocketDisconnect` ⚠, &amp; 🌐 🎏 👩‍💻 🔜 📨 📧 💖:
```
Client #1596980209979 left the chat
```
!!! tip
📱 🔛 ⭐ &amp; 🙅 🖼 🎦 ❔ 🍵 &amp; 📻 📧 📚 *️⃣ 🔗.
✋️ ✔️ 🤯 👈, 🌐 🍵 💾, 👁 📇, ⚫️ 🔜 🕴 👷 ⏪ 🛠️ 🏃, &amp; 🔜 🕴 👷 ⏮️ 👁 🛠️.
🚥 👆 💪 🕳 ⏩ 🛠️ ⏮️ FastAPI ✋️ 👈 🌖 🏋️, 🐕‍🦺 ✳, ✳ ⚖️ 🎏, ✅ <a href="https://github.com/encode/broadcaster" class="external-link" target="_blank">🗜/📻</a>.
## 🌅 ℹ
💡 🌅 🔃 🎛, ✅ 💃 🧾:
* <a href="https://www.starlette.io/websockets/" class="external-link" target="_blank"> `WebSocket` 🎓</a>.
* <a href="https://www.starlette.io/endpoints/#websocketendpoint" class="external-link" target="_blank">🎓-⚓️ *️⃣ 🚚</a>.

37
docs/em/docs/advanced/wsgi.md

@ -0,0 +1,37 @@
# ✅ 🇨🇻 - 🏺, ✳, 🎏
👆 💪 🗻 🇨🇻 🈸 👆 👀 ⏮️ [🎧 🈸 - 🗻](./sub-applications.md){.internal-link target=_blank}, [⛅ 🗳](./behind-a-proxy.md){.internal-link target=_blank}.
👈, 👆 💪 ⚙️ `WSGIMiddleware` &amp; ⚙️ ⚫️ 🎁 👆 🇨🇻 🈸, 🖼, 🏺, ✳, ♒️.
## ⚙️ `WSGIMiddleware`
👆 💪 🗄 `WSGIMiddleware`.
⤴️ 🎁 🇨🇻 (✅ 🏺) 📱 ⏮️ 🛠️.
&amp; ⤴️ 🗻 👈 🔽 ➡.
```Python hl_lines="2-3 22"
{!../../../docs_src/wsgi/tutorial001.py!}
```
## ✅ ⚫️
🔜, 🔠 📨 🔽 ➡ `/v1/` 🔜 🍵 🏺 🈸.
&amp; 🎂 🔜 🍵 **FastAPI**.
🚥 👆 🏃 ⚫️ ⏮️ Uvicorn &amp; 🚶 <a href="http://localhost:8000/v1/" class="external-link" target="_blank">http://localhost:8000/v1/</a> 👆 🔜 👀 📨 ⚪️➡️ 🏺:
```txt
Hello, World from Flask!
```
&amp; 🚥 👆 🚶 <a href="http://localhost:8000/v2" class="external-link" target="_blank">http://localhost:8000/v2</a> 👆 🔜 👀 📨 ⚪️➡️ FastAPI:
```JSON
{
"message": "Hello World"
}
```

414
docs/em/docs/alternatives.md

@ -0,0 +1,414 @@
# 🎛, 🌈 &amp; 🔺
⚫️❔ 😮 **FastAPI**, ❔ ⚫️ 🔬 🎏 🎛 &amp; ⚫️❔ ⚫️ 🇭🇲 ⚪️➡️ 👫.
## 🎶
**FastAPI** 🚫🔜 🔀 🚥 🚫 ⏮️ 👷 🎏.
📤 ✔️ 📚 🧰 ✍ ⏭ 👈 ✔️ ℹ 😮 🚮 🏗.
👤 ✔️ ❎ 🏗 🆕 🛠️ 📚 1️⃣2️⃣🗓️. 🥇 👤 🔄 ❎ 🌐 ⚒ 📔 **FastAPI** ⚙️ 📚 🎏 🛠️, 🔌-🔌, &amp; 🧰.
✋️ ☝, 📤 🙅‍♂ 🎏 🎛 🌘 🏗 🕳 👈 🚚 🌐 👫 ⚒, ✊ 🏆 💭 ⚪️➡️ ⏮️ 🧰, &amp; 🌀 👫 🏆 🌌 💪, ⚙️ 🇪🇸 ⚒ 👈 ➖🚫 💪 ⏭ (🐍 3️⃣.6️⃣ ➕ 🆎 🔑).
## ⏮️ 🧰
### <a href="https://www.djangoproject.com/" class="external-link" target="_blank"></a>
⚫️ 🌅 🌟 🐍 🛠️ &amp; 🛎 🕴. ⚫️ ⚙️ 🏗 ⚙️ 💖 👱📔.
⚫️ 📶 😆 🔗 ⏮️ 🔗 💽 (💖 ✳ ⚖️ ✳),, ✔️ ☁ 💽 (💖 🗄, ✳, 👸, ♒️) 👑 🏪 🚒 🚫 📶 ⏩.
⚫️ ✍ 🏗 🕸 👩‍💻, 🚫 ✍ 🔗 ⚙️ 🏛 🕸 (💖 😥, Vue.js &amp; 📐) ⚖️ 🎏 ⚙️ (💖 <abbr title="Internet of Things"></abbr> 📳) 🔗 ⏮️ ⚫️.
### <a href="https://www.django-rest-framework.org/" class="external-link" target="_blank">✳ 🎂 🛠️</a>
✳ 🎂 🛠️ ✍ 🗜 🧰 🏗 🕸 🔗 ⚙️ ✳ 🔘, 📉 🚮 🛠️ 🛠️.
⚫️ ⚙️ 📚 🏢 ✅ 🦎, 🟥 👒 &amp; 🎟.
⚫️ 🕐 🥇 🖼 **🏧 🛠️ 🧾**, &amp; 👉 🎯 🕐 🥇 💭 👈 😮 "🔎" **FastAPI**.
!!! note
✳ 🎂 🛠️ ✍ ✡ 🇺🇸🏛. 🎏 👼 💃 &amp; Uvicorn, 🔛 ❔ **FastAPI** ⚓️.
!!! check "😮 **FastAPI** "
✔️ 🏧 🛠️ 🧾 🕸 👩‍💻 🔢.
### <a href="https://flask.palletsprojects.com" class="external-link" target="_blank">🏺</a>
🏺 "🕸", ⚫️ 🚫 🔌 💽 🛠️ 🚫 📚 👜 👈 👟 🔢 ✳.
👉 🦁 &amp; 💪 ✔ 🔨 👜 💖 ⚙️ ☁ 💽 👑 💽 💾 ⚙️.
⚫️ 📶 🙅, ⚫️ 📶 🏋️ 💡, 👐 🧾 🤚 🙁 📡 ☝.
⚫️ 🛎 ⚙️ 🎏 🈸 👈 🚫 🎯 💪 💽, 👩‍💻 🧾, ⚖️ 🙆 📚 ⚒ 👈 👟 🏤-🏗 ✳. 👐 📚 👫 ⚒ 💪 🚮 ⏮️ 🔌-🔌.
👉 ⚖ 🍕, &amp; ➖ "🕸" 👈 💪 ↔ 📔 ⚫️❔ ⚫️❔ 💪 🔑 ⚒ 👈 👤 💚 🚧.
👐 🦁 🏺, ⚫️ 😑 💖 👍 🏏 🏗 🔗. ⏭ 👜 🔎 "✳ 🎂 🛠️" 🏺.
!!! check "😮 **FastAPI** "
◾-🛠️. ⚒ ⚫️ ⏩ 🌀 &amp; 🏏 🧰 &amp; 🍕 💪.
✔️ 🙅 &amp; ⏩ ⚙️ 🕹 ⚙️.
### <a href="https://requests.readthedocs.io" class="external-link" target="_blank">📨</a>
**FastAPI** 🚫 🤙 🎛 **📨**. 👫 ↔ 📶 🎏.
⚫️ 🔜 🤙 ⚠ ⚙️ 📨 *🔘* FastAPI 🈸.
✋️, FastAPI 🤚 🌈 ⚪️➡️ 📨.
**📨** 🗃 *🔗* ⏮️ 🔗 (👩‍💻), ⏪ **FastAPI** 🗃 *🏗* 🔗 (💽).
👫, 🌖 ⚖️ 🌘, 🔄 🔚, 🔗 🔠 🎏.
📨 ✔️ 📶 🙅 &amp; 🏋️ 🔧, ⚫️ 📶 ⏩ ⚙️, ⏮️ 🤔 🔢. ✋️ 🎏 🕰, ⚫️ 📶 🏋️ &amp; 🛃.
👈 ⚫️❔, 💬 🛂 🕸:
&gt; 📨 1️⃣ 🏆 ⏬ 🐍 📦 🌐 🕰
🌌 👆 ⚙️ ⚫️ 📶 🙅. 🖼, `GET` 📨, 👆 🔜 ✍:
```Python
response = requests.get("http://example.com/some/url")
```
FastAPI 😑 🛠️ *➡ 🛠️* 💪 👀 💖:
```Python hl_lines="1"
@app.get("/some/url")
def read_url():
return {"message": "Hello World"}
```
👀 🔀 `requests.get(...)` &amp; `@app.get(...)`.
!!! check "😮 **FastAPI** "
* ✔️ 🙅 &amp; 🏋️ 🛠️.
* ⚙️ 🇺🇸🔍 👩‍🔬 📛 (🛠️) 🔗, 🎯 &amp; 🏋️ 🌌.
* ✔️ 🤔 🔢, ✋️ 🏋️ 🛃.
### <a href="https://swagger.io/" class="external-link" target="_blank">🦁</a> / <a href="https://github.com/OAI/OpenAPI-Specification/" class="external-link" target="_blank">🗄</a>
👑 ⚒ 👤 💚 ⚪️➡️ ✳ 🎂 🛠️ 🏧 🛠️ 🧾.
⤴️ 👤 🔎 👈 📤 🐩 📄 🔗, ⚙️ 🎻 (⚖️ 📁, ↔ 🎻) 🤙 🦁.
&amp; 📤 🕸 👩‍💻 🔢 🦁 🛠️ ⏪ ✍. , 💆‍♂ 💪 🏗 🦁 🧾 🛠️ 🔜 ✔ ⚙️ 👉 🕸 👩‍💻 🔢 🔁.
☝, 🦁 👐 💾 🏛, 📁 🗄.
👈 ⚫️❔ 🕐❔ 💬 🔃 ⏬ 2️⃣.0️⃣ ⚫️ ⚠ 💬 "🦁", &amp; ⏬ 3️⃣ ➕ "🗄".
!!! check "😮 **FastAPI** "
🛠️ &amp; ⚙️ 📂 🐩 🛠️ 🔧, ↩️ 🛃 🔗.
&amp; 🛠️ 🐩-⚓️ 👩‍💻 🔢 🧰:
* <a href="https://github.com/swagger-api/swagger-ui" class="external-link" target="_blank">🦁 🎚</a>
* <a href="https://github.com/Rebilly/ReDoc" class="external-link" target="_blank">📄</a>
👫 2️⃣ 👐 ➖ 📶 🌟 &amp; ⚖, ✋️ 🔨 ⏩ 🔎, 👆 💪 🔎 💯 🌖 🎛 👩‍💻 🔢 🗄 (👈 👆 💪 ⚙️ ⏮️ **FastAPI**).
### 🏺 🎂 🛠️
📤 📚 🏺 🎂 🛠️, ✋️ ⏮️ 💰 🕰 &amp; 👷 🔘 🔬 👫, 👤 🔎 👈 📚 😞 ⚖️ 🚫, ⏮️ 📚 🧍 ❔ 👈 ⚒ 👫 🙃.
### <a href="https://marshmallow.readthedocs.io/en/stable/" class="external-link" target="_blank">🍭</a>
1️⃣ 👑 ⚒ 💪 🛠️ ⚙️ 📊 "<abbr title="also called marshalling, conversion">🛠️</abbr>" ❔ ✊ 📊 ⚪️➡️ 📟 (🐍) &amp; 🏭 ⚫️ 🔘 🕳 👈 💪 📨 🔘 🕸. 🖼, 🏭 🎚 ⚗ 📊 ⚪️➡️ 💽 🔘 🎻 🎚. 🏭 `datetime` 🎚 🔘 🎻, ♒️.
➕1️⃣ 🦏 ⚒ 💚 🔗 💽 🔬, ⚒ 💭 👈 💽 ☑, 🤝 🎯 🔢. 🖼, 👈 🏑 `int`, &amp; 🚫 🎲 🎻. 👉 ✴️ ⚠ 📨 💽.
🍵 💽 🔬 ⚙️, 👆 🔜 ✔️ 🌐 ✅ ✋, 📟.
👫 ⚒ ⚫️❔ 🍭 🏗 🚚. ⚫️ 👑 🗃, &amp; 👤 ✔️ ⚙️ ⚫️ 📚 ⏭.
✋️ ⚫️ ✍ ⏭ 📤 🔀 🐍 🆎 🔑. , 🔬 🔠 <abbr title="the definition of how data should be formed">🔗</abbr> 👆 💪 ⚙️ 🎯 🇨🇻 &amp; 🎓 🚚 🍭.
!!! check "😮 **FastAPI** "
⚙️ 📟 🔬 "🔗" 👈 🚚 💽 🆎 &amp; 🔬, 🔁.
### <a href="https://webargs.readthedocs.io/en/latest/" class="external-link" target="_blank">Webarg</a>
➕1️⃣ 🦏 ⚒ ✔ 🔗 <abbr title="reading and converting to Python data"></abbr> 📊 ⚪️➡️ 📨 📨.
Webarg 🧰 👈 ⚒ 🚚 👈 🔛 🔝 📚 🛠️, 🔌 🏺.
⚫️ ⚙️ 🍭 🔘 💽 🔬. &amp; ⚫️ ✍ 🎏 👩‍💻.
⚫️ 👑 🧰 &amp; 👤 ✔️ ⚙️ ⚫️ 📚 💁‍♂️, ⏭ ✔️ **FastAPI**.
!!! info
Webarg ✍ 🎏 🍭 👩‍💻.
!!! check "😮 **FastAPI** "
✔️ 🏧 🔬 📨 📨 💽.
### <a href="https://apispec.readthedocs.io/en/stable/" class="external-link" target="_blank">APISpec</a>
🍭 &amp; Webarg 🚚 🔬, ✍ &amp; 🛠️ 🔌-🔌.
✋️ 🧾 ❌. ⤴️ APISpec ✍.
⚫️ 🔌-📚 🛠️ (&amp; 📤 🔌-💃 💁‍♂️).
🌌 ⚫️ 👷 👈 👆 ✍ 🔑 🔗 ⚙️ 📁 📁 🔘 #️⃣ 🔠 🔢 🚚 🛣.
&amp; ⚫️ 🏗 🗄 🔗.
👈 ❔ ⚫️ 👷 🏺, 💃, 🆘, ♒️.
✋️ ⤴️, 👥 ✔️ 🔄 ⚠ ✔️ ◾-❕, 🔘 🐍 🎻 (🦏 📁).
👨‍🎨 💪 🚫 ℹ 🌅 ⏮️ 👈. &amp; 🚥 👥 🔀 🔢 ⚖️ 🍭 🔗 &amp; 💭 🔀 👈 📁#️⃣, 🏗 🔗 🔜 ❌.
!!! info
APISpec ✍ 🎏 🍭 👩‍💻.
!!! check "😮 **FastAPI** "
🐕‍🦺 📂 🐩 🛠️, 🗄.
### <a href="https://flask-apispec.readthedocs.io/en/latest/" class="external-link" target="_blank">🏺-Apispec</a>
⚫️ 🏺 🔌 -, 👈 👔 👯‍♂️ Webarg, 🍭 &amp; APISpec.
⚫️ ⚙️ ℹ ⚪️➡️ Webarg &amp; 🍭 🔁 🏗 🗄 🔗, ⚙️ APISpec.
⚫️ 👑 🧰, 📶 🔽-📈. ⚫️ 🔜 🌌 🌖 🌟 🌘 📚 🏺 🔌-🔌 👅 📤. ⚫️ 💪 ↩️ 🚮 🧾 ➖ 💁‍♂️ 🩲 &amp; 📝.
👉 ❎ ✔️ ✍ 📁 (➕1️⃣ ❕) 🔘 🐍 ✍.
👉 🌀 🏺, 🏺-Apispec ⏮️ 🍭 &amp; Webarg 👇 💕 👩‍💻 📚 ⏭ 🏗 **FastAPI**.
⚙️ ⚫️ ↘️ 🏗 📚 🏺 🌕-📚 🚂. 👫 👑 📚 👤 (&amp; 📚 🔢 🏉) ✔️ ⚙️ 🆙 🔜:
* <a href="https://github.com/tiangolo/full-stack" class="external-link" target="_blank">https://github.com/tiangolo/full-stack</a>
* <a href="https://github.com/tiangolo/full-stack-flask-couchbase" class="external-link" target="_blank">https://github.com/tiangolo/full-stack-flask-couchbase</a>
* <a href="https://github.com/tiangolo/full-stack-flask-couchdb" class="external-link" target="_blank">https://github.com/tiangolo/full-stack-flask-couchdb</a>
&amp; 👫 🎏 🌕-📚 🚂 🧢 [**FastAPI** 🏗 🚂](project-generation.md){.internal-link target=_blank}.
!!! info
🏺-Apispec ✍ 🎏 🍭 👩‍💻.
!!! check "😮 **FastAPI** "
🏗 🗄 🔗 🔁, ⚪️➡️ 🎏 📟 👈 🔬 🛠️ &amp; 🔬.
### <a href="https://nestjs.com/" class="external-link" target="_blank">NestJS</a> (&amp; <a href="https://angular.io/" class="external-link" target="_blank">📐</a>)
👉 ➖🚫 🚫 🐍, NestJS 🕸 (📕) ✳ 🛠️ 😮 📐.
⚫️ 🏆 🕳 🙁 🎏 ⚫️❔ 💪 🔨 ⏮️ 🏺-Apispec.
⚫️ ✔️ 🛠️ 🔗 💉 ⚙️, 😮 📐 2️⃣. ⚫️ 🚚 🏤-® "💉" (💖 🌐 🎏 🔗 💉 ⚙️ 👤 💭),, ⚫️ 🚮 🎭 &amp; 📟 🔁.
🔢 🔬 ⏮️ 📕 🆎 (🎏 🐍 🆎 🔑), 👨‍🎨 🐕‍🦺 👍.
✋️ 📕 📊 🚫 🛡 ⏮️ 📹 🕸, ⚫️ 🚫🔜 ⚓️ 🔛 🆎 🔬 🔬, 🛠️ &amp; 🧾 🎏 🕰. ↩️ 👉 &amp; 🔧 🚫, 🤚 🔬, 🛠️ &amp; 🏧 🔗 ⚡, ⚫️ 💪 🚮 👨‍🎨 📚 🥉. , ⚫️ ▶️️ 🔁.
⚫️ 💪 🚫 🍵 🔁 🏷 📶 👍. , 🚥 🎻 💪 📨 🎻 🎚 👈 ✔️ 🔘 🏑 👈 🔄 🐦 🎻 🎚, ⚫️ 🚫🔜 ☑ 📄 &amp; ✔.
!!! check "😮 **FastAPI** "
⚙️ 🐍 🆎 ✔️ 👑 👨‍🎨 🐕‍🦺.
✔️ 🏋️ 🔗 💉 ⚙️. 🔎 🌌 📉 📟 🔁.
### <a href="https://sanic.readthedocs.io/en/latest/" class="external-link" target="_blank">🤣</a>
⚫️ 🕐 🥇 📶 ⏩ 🐍 🛠️ ⚓️ 🔛 `asyncio`. ⚫️ ⚒ 📶 🎏 🏺.
!!! note "📡 ℹ"
⚫️ ⚙️ <a href="https://github.com/MagicStack/uvloop" class="external-link" target="_blank">`uvloop`</a> ↩️ 🔢 🐍 `asyncio` ➰. 👈 ⚫️❔ ⚒ ⚫️ ⏩.
⚫️ 🎯 😮 Uvicorn &amp; 💃, 👈 ⏳ ⏩ 🌘 🤣 📂 📇.
!!! check "😮 **FastAPI** "
🔎 🌌 ✔️ 😜 🎭.
👈 ⚫️❔ **FastAPI** ⚓️ 🔛 💃, ⚫️ ⏩ 🛠️ 💪 (💯 🥉-🥳 📇).
### <a href="https://falconframework.org/" class="external-link" target="_blank">🦅</a>
🦅 ➕1️⃣ ↕ 🎭 🐍 🛠️, ⚫️ 🔧 ⭐, &amp; 👷 🏛 🎏 🛠️ 💖 🤗.
⚫️ 🏗 ✔️ 🔢 👈 📨 2️⃣ 🔢, 1️⃣ "📨" &amp; 1️⃣ "📨". ⤴️ 👆 "✍" 🍕 ⚪️➡️ 📨, &amp; "✍" 🍕 📨. ↩️ 👉 🔧, ⚫️ 🚫 💪 📣 📨 🔢 &amp; 💪 ⏮️ 🐩 🐍 🆎 🔑 🔢 🔢.
, 💽 🔬, 🛠️, &amp; 🧾, ✔️ ⌛ 📟, 🚫 🔁. ⚖️ 👫 ✔️ 🛠️ 🛠️ 🔛 🔝 🦅, 💖 🤗. 👉 🎏 🔺 🔨 🎏 🛠️ 👈 😮 🦅 🔧, ✔️ 1️⃣ 📨 🎚 &amp; 1️⃣ 📨 🎚 🔢.
!!! check "😮 **FastAPI** "
🔎 🌌 🤚 👑 🎭.
⤴️ ⏮️ 🤗 (🤗 ⚓️ 🔛 🦅) 😮 **FastAPI** 📣 `response` 🔢 🔢.
👐 FastAPI ⚫️ 📦, &amp; ⚙️ ✴️ ⚒ 🎚, 🍪, &amp; 🎛 👔 📟.
### <a href="https://moltenframework.com/" class="external-link" target="_blank"></a>
👤 🔎 ♨ 🥇 ▶️ 🏗 **FastAPI**. &amp; ⚫️ ✔️ 🎏 💭:
* ⚓️ 🔛 🐍 🆎 🔑.
* 🔬 &amp; 🧾 ⚪️➡️ 👫 🆎.
* 🔗 💉 ⚙️.
⚫️ 🚫 ⚙️ 💽 🔬, 🛠️ &amp; 🧾 🥉-🥳 🗃 💖 Pydantic, ⚫️ ✔️ 🚮 👍. , 👫 💽 🆎 🔑 🔜 🚫 ♻ 💪.
⚫️ 🚚 🐥 🍖 🌅 🔁 📳. &amp; ⚫️ ⚓️ 🔛 🇨🇻 (↩️ 🔫), ⚫️ 🚫 🔧 ✊ 📈 ↕-🎭 🚚 🧰 💖 Uvicorn, 💃 &amp; 🤣.
🔗 💉 ⚙️ 🚚 🏤-® 🔗 &amp; 🔗 ❎ 🧢 🔛 📣 🆎. , ⚫️ 🚫 💪 📣 🌅 🌘 1️⃣ "🦲" 👈 🚚 🎯 🆎.
🛣 📣 👁 🥉, ⚙️ 🔢 📣 🎏 🥉 (↩️ ⚙️ 👨‍🎨 👈 💪 🥉 ▶️️ 🔛 🔝 🔢 👈 🍵 🔗). 👉 🔐 ❔ ✳ 🔨 ⚫️ 🌘 ❔ 🏺 (&amp; 💃) 🔨 ⚫️. ⚫️ 🎏 📟 👜 👈 📶 😆 🔗.
!!! check "😮 **FastAPI** "
🔬 ➕ 🔬 💽 🆎 ⚙️ "🔢" 💲 🏷 🔢. 👉 📉 👨‍🎨 🐕‍🦺, &amp; ⚫️ 🚫 💪 Pydantic ⏭.
👉 🤙 😮 🛠️ 🍕 Pydantic, 🐕‍🦺 🎏 🔬 📄 👗 (🌐 👉 🛠️ 🔜 ⏪ 💪 Pydantic).
### <a href="https://www.hug.rest/" class="external-link" target="_blank">🤗</a>
🤗 🕐 🥇 🛠️ 🛠️ 📄 🛠️ 🔢 🆎 ⚙️ 🐍 🆎 🔑. 👉 👑 💭 👈 😮 🎏 🧰 🎏.
⚫️ ⚙️ 🛃 🆎 🚮 📄 ↩️ 🐩 🐍 🆎, ✋️ ⚫️ 🦏 🔁 ⏩.
⚫️ 🕐 🥇 🛠️ 🏗 🛃 🔗 📣 🎂 🛠️ 🎻.
⚫️ 🚫 ⚓️ 🔛 🐩 💖 🗄 &amp; 🎻 🔗. ⚫️ 🚫🔜 🎯 🛠️ ⚫️ ⏮️ 🎏 🧰, 💖 🦁 🎚. ✋️ 🔄, ⚫️ 📶 💡 💭.
⚫️ ✔️ 😌, ⭐ ⚒: ⚙️ 🎏 🛠️, ⚫️ 💪 ✍ 🔗 &amp; 🇳🇨.
⚫️ ⚓️ 🔛 ⏮️ 🐩 🔁 🐍 🕸 🛠️ (🇨🇻), ⚫️ 💪 🚫 🍵 *️⃣ &amp; 🎏 👜, 👐 ⚫️ ✔️ ↕ 🎭 💁‍♂️.
!!! info
🤗 ✍ ✡ 🗄, 🎏 👼 <a href="https://github.com/timothycrosley/isort" class="external-link" target="_blank">`isort`</a>, 👑 🧰 🔁 😇 🗄 🐍 📁.
!!! check "💭 😮 **FastAPI**"
🤗 😮 🍕 APIStar, &amp; 1️⃣ 🧰 👤 🔎 🏆 👍, 🌟 APIStar.
🤗 ℹ 😍 **FastAPI** ⚙️ 🐍 🆎 🔑 📣 🔢, &amp; 🏗 🔗 ⚖ 🛠️ 🔁.
🤗 😮 **FastAPI** 📣 `response` 🔢 🔢 ⚒ 🎚 &amp; 🍪.
### <a href="https://github.com/encode/apistar" class="external-link" target="_blank">APIStar</a> (&lt;= 0️⃣.5️⃣)
▶️️ ⏭ 🤔 🏗 **FastAPI** 👤 🔎 **APIStar** 💽. ⚫️ ✔️ 🌖 🌐 👤 👀 &amp; ✔️ 👑 🔧.
⚫️ 🕐 🥇 🛠️ 🛠️ ⚙️ 🐍 🆎 🔑 📣 🔢 &amp; 📨 👈 👤 ⏱ 👀 (⏭ NestJS &amp; ♨). 👤 🔎 ⚫️ 🌅 ⚖️ 🌘 🎏 🕰 🤗. ✋️ APIStar ⚙️ 🗄 🐩.
⚫️ ✔️ 🏧 💽 🔬, 💽 🛠️ &amp; 🗄 🔗 ⚡ ⚓️ 🔛 🎏 🆎 🔑 📚 🥉.
💪 🔗 🔑 🚫 ⚙️ 🎏 🐍 🆎 🔑 💖 Pydantic, ⚫️ 🍖 🌅 🎏 🍭,, 👨‍🎨 🐕‍🦺 🚫🔜 👍, ✋️, APIStar 🏆 💪 🎛.
⚫️ ✔️ 🏆 🎭 📇 🕰 (🕴 💥 💃).
🥇, ⚫️ 🚫 ✔️ 🏧 🛠️ 🧾 🕸 🎚, ✋️ 👤 💭 👤 💪 🚮 🦁 🎚 ⚫️.
⚫️ ✔️ 🔗 💉 ⚙️. ⚫️ ✔ 🏤-® 🦲, 🎏 🧰 🔬 🔛. ✋️, ⚫️ 👑 ⚒.
👤 🙅 💪 ⚙️ ⚫️ 🌕 🏗, ⚫️ 🚫 ✔️ 💂‍♂ 🛠️,, 👤 🚫 🚫 ❎ 🌐 ⚒ 👤 ✔️ ⏮️ 🌕-📚 🚂 ⚓️ 🔛 🏺-Apispec. 👤 ✔️ 👇 📈 🏗 ✍ 🚲 📨 ❎ 👈 🛠️.
✋️ ⤴️, 🏗 🎯 🔀.
⚫️ 🙅‍♂ 📏 🛠️ 🕸 🛠️, 👼 💪 🎯 🔛 💃.
🔜 APIStar ⚒ 🧰 ✔ 🗄 🔧, 🚫 🕸 🛠️.
!!! info
APIStar ✍ ✡ 🇺🇸🏛. 🎏 👨 👈 ✍:
* ✳ 🎂 🛠️
* 💃 (❔ **FastAPI** ⚓️)
* Uvicorn (⚙️ 💃 &amp; **FastAPI**)
!!! check "😮 **FastAPI** "
🔀.
💭 📣 💗 👜 (💽 🔬, 🛠️ &amp; 🧾) ⏮️ 🎏 🐍 🆎, 👈 🎏 🕰 🚚 👑 👨‍🎨 🐕‍🦺, 🕳 👤 🤔 💎 💭.
&amp; ⏮️ 🔎 📏 🕰 🎏 🛠️ &amp; 🔬 📚 🎏 🎛, APIStar 🏆 🎛 💪.
⤴️ APIStar ⛔️ 🔀 💽 &amp; 💃 ✍, &amp; 🆕 👻 🏛 ✅ ⚙️. 👈 🏁 🌈 🏗 **FastAPI**.
👤 🤔 **FastAPI** "🛐 👨‍💼" APIStar, ⏪ 📉 &amp; 📈 ⚒, ⌨ ⚙️, &amp; 🎏 🍕, ⚓️ 🔛 🏫 ⚪️➡️ 🌐 👉 ⏮️ 🧰.
## ⚙️ **FastAPI**
### <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a>
Pydantic 🗃 🔬 💽 🔬, 🛠️ &amp; 🧾 (⚙️ 🎻 🔗) ⚓️ 🔛 🐍 🆎 🔑.
👈 ⚒ ⚫️ 📶 🏋️.
⚫️ ⭐ 🍭. 👐 ⚫️ ⏩ 🌘 🍭 📇. &amp; ⚫️ ⚓️ 🔛 🎏 🐍 🆎 🔑, 👨‍🎨 🐕‍🦺 👑.
!!! check "**FastAPI** ⚙️ ⚫️"
🍵 🌐 💽 🔬, 💽 🛠️ &amp; 🏧 🏷 🧾 (⚓️ 🔛 🎻 🔗).
**FastAPI** ⤴️ ✊ 👈 🎻 🔗 💽 &amp; 🚮 ⚫️ 🗄, ↖️ ⚪️➡️ 🌐 🎏 👜 ⚫️ 🔨.
### <a href="https://www.starlette.io/" class="external-link" target="_blank">💃</a>
💃 💿 <abbr title="The new standard for building asynchronous Python web">🔫</abbr> 🛠️/🧰, ❔ 💯 🏗 ↕-🎭 ✳ 🐕‍🦺.
⚫️ 📶 🙅 &amp; 🏋️. ⚫️ 🔧 💪 🏧, &amp; ✔️ 🔧 🦲.
⚫️ ✔️:
* 🤙 🎆 🎭.
* *️⃣ 🐕‍🦺.
* -🛠️ 🖥 📋.
* 🕴 &amp; 🤫 🎉.
* 💯 👩‍💻 🏗 🔛 🇸🇲.
* ⚜, 🗜, 🎻 📁, 🎏 📨.
* 🎉 &amp; 🍪 🐕‍🦺.
* 1️⃣0️⃣0️⃣ 💯 💯 💰.
* 1️⃣0️⃣0️⃣ 💯 🆎 ✍ ✍.
* 👩‍❤‍👨 🏋️ 🔗.
💃 ⏳ ⏩ 🐍 🛠️ 💯. 🕴 💥 Uvicorn, ❔ 🚫 🛠️, ✋️ 💽.
💃 🚚 🌐 🔰 🕸 🕸 🛠️.
✋️ ⚫️ 🚫 🚚 🏧 💽 🔬, 🛠️ ⚖️ 🧾.
👈 1️⃣ 👑 👜 👈 **FastAPI** 🚮 🔛 🔝, 🌐 ⚓️ 🔛 🐍 🆎 🔑 (⚙️ Pydantic). 👈, ➕ 🔗 💉 ⚙️, 💂‍♂ 🚙, 🗄 🔗 ⚡, ♒️.
!!! note "📡 ℹ"
🔫 🆕 "🐩" ➖ 🛠️ ✳ 🐚 🏉 👨‍🎓. ⚫️ 🚫 "🐍 🐩" (🇩🇬), 👐 👫 🛠️ 🔨 👈.
👐, ⚫️ ⏪ ➖ ⚙️ "🐩" 📚 🧰. 👉 📉 📉 🛠️, 👆 💪 🎛 Uvicorn 🙆 🎏 🔫 💽 (💖 👸 ⚖️ Hypercorn), ⚖️ 👆 💪 🚮 🔫 🔗 🧰, 💖 `python-socketio`.
!!! check "**FastAPI** ⚙️ ⚫️"
🍵 🌐 🐚 🕸 🍕. ❎ ⚒ 🔛 🔝.
🎓 `FastAPI` ⚫️ 😖 🔗 ⚪️➡️ 🎓 `Starlette`.
, 🕳 👈 👆 💪 ⏮️ 💃, 👆 💪 ⚫️ 🔗 ⏮️ **FastAPI**, ⚫️ 🌖 💃 🔛 💊.
### <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>
Uvicorn 🌩-⏩ 🔫 💽, 🏗 🔛 uvloop &amp; httptool.
⚫️ 🚫 🕸 🛠️, ✋️ 💽. 🖼, ⚫️ 🚫 🚚 🧰 🕹 ➡. 👈 🕳 👈 🛠️ 💖 💃 (⚖️ **FastAPI**) 🔜 🚚 🔛 🔝.
⚫️ 👍 💽 💃 &amp; **FastAPI**.
!!! check "**FastAPI** 👍 ⚫️"
👑 🕸 💽 🏃 **FastAPI** 🈸.
👆 💪 🌀 ⚫️ ⏮️ 🐁, ✔️ 🔁 👁-🛠️ 💽.
✅ 🌅 ℹ [🛠️](deployment/index.md){.internal-link target=_blank} 📄.
## 📇 &amp; 🚅
🤔, 🔬, &amp; 👀 🔺 🖖 Uvicorn, 💃 &amp; FastAPI, ✅ 📄 🔃 [📇](benchmarks.md){.internal-link target=_blank}.

430
docs/em/docs/async.md

@ -0,0 +1,430 @@
# 🛠️ &amp; 🔁 / ⌛
ℹ 🔃 `async def`*➡ 🛠️ 🔢* &amp; 🖥 🔃 🔁 📟, 🛠️, &amp; 🔁.
## 🏃 ❓
<abbr title="too long; didn't read"><strong>🆑;👩‍⚕️:</strong></abbr>
🚥 👆 ⚙️ 🥉 🥳 🗃 👈 💬 👆 🤙 👫 ⏮️ `await`, 💖:
```Python
results = await some_library()
```
⤴️, 📣 👆 *➡ 🛠️ 🔢* ⏮️ `async def` 💖:
```Python hl_lines="2"
@app.get('/')
async def read_results():
results = await some_library()
return results
```
!!! note
👆 💪 🕴 ⚙️ `await` 🔘 🔢 ✍ ⏮️ `async def`.
---
🚥 👆 ⚙️ 🥉 🥳 🗃 👈 🔗 ⏮️ 🕳 (💽, 🛠️, 📁 ⚙️, ♒️.) &amp; 🚫 ✔️ 🐕‍🦺 ⚙️ `await`, (👉 ⏳ 💼 🌅 💽 🗃), ⤴️ 📣 👆 *➡ 🛠️ 🔢* 🛎, ⏮️ `def`, 💖:
```Python hl_lines="2"
@app.get('/')
def results():
results = some_library()
return results
```
---
🚥 👆 🈸 (😫) 🚫 ✔️ 🔗 ⏮️ 🕳 🙆 &amp; ⌛ ⚫️ 📨, ⚙️ `async def`.
---
🚥 👆 🚫 💭, ⚙️ 😐 `def`.
---
**🗒**: 👆 💪 🌀 `def` &amp; `async def` 👆 *➡ 🛠️ 🔢* 🌅 👆 💪 &amp; 🔬 🔠 1️⃣ ⚙️ 🏆 🎛 👆. FastAPI 🔜 ▶️️ 👜 ⏮️ 👫.
😆, 🙆 💼 🔛, FastAPI 🔜 👷 🔁 &amp; 📶 ⏩.
✋️ 📄 📶 🔛, ⚫️ 🔜 💪 🎭 🛠️.
## 📡 ℹ
🏛 ⏬ 🐍 ✔️ 🐕‍🦺 **"🔁 📟"** ⚙️ 🕳 🤙 **"🔁"**, ⏮️ **`async` &amp; `await`** ❕.
➡️ 👀 👈 🔤 🍕 📄 🔛:
* **🔁 📟**
* **`async` &amp; `await`**
* **🔁**
## 🔁 📟
🔁 📟 ⛓ 👈 🇪🇸 👶 ✔️ 🌌 💬 💻 / 📋 👶 👈 ☝ 📟, ⚫️ 👶 🔜 ✔️ ⌛ *🕳 🙆* 🏁 👱 🙆. ➡️ 💬 👈 *🕳 🙆* 🤙 "🐌-📁" 👶.
, ⏮️ 👈 🕰, 💻 💪 🚶 &amp; 🎏 👷, ⏪ "🐌-📁" 👶 🏁.
⤴️ 💻 / 📋 👶 🔜 👟 🔙 🔠 🕰 ⚫️ ✔️ 🤞 ↩️ ⚫️ ⌛ 🔄, ⚖️ 🕐❔ ⚫️ 👶 🏁 🌐 👷 ⚫️ ✔️ 👈 ☝. &amp; ⚫️ 👶 🔜 👀 🚥 🙆 📋 ⚫️ ⌛ ✔️ ⏪ 🏁, 🤸 ⚫️❔ ⚫️ ✔️.
⏭, ⚫️ 👶 ✊ 🥇 📋 🏁 (➡️ 💬, 👆 "🐌-📁" 👶) &amp; 😣 ⚫️❔ ⚫️ ✔️ ⏮️ ⚫️.
👈 "⌛ 🕳 🙆" 🛎 🔗 <abbr title="Input and Output">👤/🅾</abbr> 🛠️ 👈 📶 "🐌" (🔬 🚅 🕹 &amp; 💾 💾), 💖 ⌛:
* 📊 ⚪️➡️ 👩‍💻 📨 🔘 🕸
* 📊 📨 👆 📋 📨 👩‍💻 🔘 🕸
* 🎚 📁 💾 ✍ ⚙️ &amp; 🤝 👆 📋
* 🎚 👆 📋 🤝 ⚙️ ✍ 💾
* 🛰 🛠️ 🛠️
* 💽 🛠️ 🏁
* 💽 🔢 📨 🏁
* ♒️.
🛠️ 🕰 🍴 ✴️ ⌛ <abbr title="Input and Output">👤/🅾</abbr> 🛠️, 👫 🤙 👫 "👤/🅾 🔗" 🛠️.
⚫️ 🤙 "🔁" ↩️ 💻 / 📋 🚫 ✔️ "🔁" ⏮️ 🐌 📋, ⌛ ☑ 🙍 👈 📋 🏁, ⏪ 🔨 🕳, 💪 ✊ 📋 🏁 &amp; 😣 👷.
↩️ 👈, 💆‍♂ "🔁" ⚙️, 🕐 🏁, 📋 💪 ⌛ ⏸ 🐥 👄 (⏲) 💻 / 📋 🏁 ⚫️❔ ⚫️ 🚶, &amp; ⤴️ 👟 🔙 ✊ 🏁 &amp; 😣 👷 ⏮️ 👫.
"🔁" (👽 "🔁") 👫 🛎 ⚙️ ⚖ "🔁", ↩️ 💻 / 📋 ⏩ 🌐 📶 🔁 ⏭ 🔀 🎏 📋, 🚥 👈 🔁 🔌 ⌛.
### 🛠️ &amp; 🍔
👉 💭 **🔁** 📟 🔬 🔛 🕣 🤙 **"🛠️"**. ⚫️ 🎏 ⚪️➡️ **"🔁"**.
**🛠️** &amp; **🔁** 👯‍♂️ 🔗 "🎏 👜 😥 🌅 ⚖️ 🌘 🎏 🕰".
✋️ ℹ 🖖 *🛠️* &amp; *🔁* 🎏.
👀 🔺, 🌈 📄 📖 🔃 🍔:
### 🛠️ 🍔
👆 🚶 ⏮️ 👆 🥰 🤚 ⏩ 🥕, 👆 🧍 ⏸ ⏪ 🏧 ✊ ✔ ⚪️➡️ 👫👫 🚪 👆. 👶
<img src="/img/async/concurrent-burgers/concurrent-burgers-01.png" class="illustration">
⤴️ ⚫️ 👆 🔄, 👆 🥉 👆 ✔ 2️⃣ 📶 🎀 🍔 👆 🥰 &amp; 👆. 👶 👶
<img src="/img/async/concurrent-burgers/concurrent-burgers-02.png" class="illustration">
🏧 💬 🕳 🍳 👨‍🍳 👫 💭 👫 ✔️ 🏗 👆 🍔 (✋️ 👫 ⏳ 🏗 🕐 ⏮️ 👩‍💻).
<img src="/img/async/concurrent-burgers/concurrent-burgers-03.png" class="illustration">
👆 💸. 👶
🏧 🤝 👆 🔢 👆 🔄.
<img src="/img/async/concurrent-burgers/concurrent-burgers-04.png" class="illustration">
⏪ 👆 ⌛, 👆 🚶 ⏮️ 👆 🥰 &amp; ⚒ 🏓, 👆 🧎 &amp; 💬 ⏮️ 👆 🥰 📏 🕰 (👆 🍔 📶 🎀 &amp; ✊ 🕰 🏗).
👆 🏖 🏓 ⏮️ 👆 🥰, ⏪ 👆 ⌛ 🍔, 👆 💪 💸 👈 🕰 😮 ❔ 👌, 🐨 &amp; 🙃 👆 🥰 👶 👶 👶.
<img src="/img/async/concurrent-burgers/concurrent-burgers-05.png" class="illustration">
⏪ ⌛ &amp; 💬 👆 🥰, ⚪️➡️ 🕰 🕰, 👆 ✅ 🔢 🖥 🔛 ⏲ 👀 🚥 ⚫️ 👆 🔄 ⏪.
⤴️ ☝, ⚫️ 😒 👆 🔄. 👆 🚶 ⏲, 🤚 👆 🍔 &amp; 👟 🔙 🏓.
<img src="/img/async/concurrent-burgers/concurrent-burgers-06.png" class="illustration">
👆 &amp; 👆 🥰 🍴 🍔 &amp; ✔️ 👌 🕰. 👶
<img src="/img/async/concurrent-burgers/concurrent-burgers-07.png" class="illustration">
!!! info
🌹 🖼 <a href="https://www.instagram.com/ketrinadrawsalot" class="external-link" target="_blank">👯 🍏</a>. 👶
---
🌈 👆 💻 / 📋 👶 👈 📖.
⏪ 👆 ⏸, 👆 ⛽ 👶, ⌛ 👆 🔄, 🚫 🔨 🕳 📶 "😌". ✋️ ⏸ ⏩ ↩️ 🏧 🕴 ✊ ✔ (🚫 🏗 👫), 👈 👌.
⤴️, 🕐❔ ⚫️ 👆 🔄, 👆 ☑ "😌" 👷, 👆 🛠️ 🍣, 💭 ⚫️❔ 👆 💚, 🤚 👆 🥰 ⚒, 💸, ✅ 👈 👆 🤝 ☑ 💵 ⚖️ 💳, ✅ 👈 👆 🈚 ☑, ✅ 👈 ✔ ✔️ ☑ 🏬, ♒️.
✋️ ⤴️, ✋️ 👆 🚫 ✔️ 👆 🍔, 👆 👷 ⏮️ 🏧 "🔛 ⏸" ⏸, ↩️ 👆 ✔️ ⌛ 👶 👆 🍔 🔜.
✋️ 👆 🚶 ↖️ ⚪️➡️ ⏲ &amp; 🧎 🏓 ⏮️ 🔢 👆 🔄, 👆 💪 🎛 👶 👆 🙋 👆 🥰, &amp; "👷" 👶 👶 🔛 👈. ⤴️ 👆 🔄 🔨 🕳 📶 "😌" 😏 ⏮️ 👆 🥰 👶.
⤴️ 🏧 👶 💬 "👤 🏁 ⏮️ 🔨 🍔" 🚮 👆 🔢 🔛 ⏲ 🖥, ✋️ 👆 🚫 🦘 💖 😜 ⏪ 🕐❔ 🖥 🔢 🔀 👆 🔄 🔢. 👆 💭 🙅‍♂ 1️⃣ 🔜 📎 👆 🍔 ↩️ 👆 ✔️ 🔢 👆 🔄, &amp; 👫 ✔️ 👫.
👆 ⌛ 👆 🥰 🏁 📖 (🏁 ⏮️ 👷 👶 / 📋 ➖ 🛠️ 👶), 😀 🖐 &amp; 💬 👈 👆 🔜 🍔 ⏸.
⤴️ 👆 🚶 ⏲ 👶, ▶️ 📋 👈 🔜 🏁 👶, ⚒ 🍔, 💬 👏 &amp; ✊ 👫 🏓. 👈 🏁 👈 🔁 / 📋 🔗 ⏮️ ⏲ ⏹. 👈 🔄, ✍ 🆕 📋, "🍴 🍔" 👶 👶, ✋️ ⏮️ 1️⃣ "🤚 🍔" 🏁 ⏹.
### 🔗 🍔
🔜 ➡️ 🌈 👫 ➖🚫 🚫 "🛠️ 🍔", ✋️ "🔗 🍔".
👆 🚶 ⏮️ 👆 🥰 🤚 🔗 ⏩ 🥕.
👆 🧍 ⏸ ⏪ 📚 (➡️ 💬 8️⃣) 🏧 👈 🎏 🕰 🍳 ✊ ✔ ⚪️➡️ 👫👫 🚪 👆.
👱 ⏭ 👆 ⌛ 👫 🍔 🔜 ⏭ 🍂 ⏲ ↩️ 🔠 8️⃣ 🏧 🚶 &amp; 🏗 🍔 ▶️️ ↖️ ⏭ 💆‍♂ ⏭ ✔.
<img src="/img/async/parallel-burgers/parallel-burgers-01.png" class="illustration">
⤴️ ⚫️ 😒 👆 🔄, 👆 🥉 👆 ✔ 2️⃣ 📶 🎀 🍔 👆 🥰 &amp; 👆.
👆 💸 👶.
<img src="/img/async/parallel-burgers/parallel-burgers-02.png" class="illustration">
🏧 🚶 👨‍🍳.
👆 ⌛, 🧍 🚪 ⏲ 👶, 👈 🙅‍♂ 1️⃣ 🙆 ✊ 👆 🍔 ⏭ 👆, 📤 🙅‍♂ 🔢 🔄.
<img src="/img/async/parallel-burgers/parallel-burgers-03.png" class="illustration">
👆 &amp; 👆 🥰 😩 🚫 ➡️ 🙆 🤚 🚪 👆 &amp; ✊ 👆 🍔 🕐❔ 👫 🛬, 👆 🚫🔜 💸 🙋 👆 🥰. 👶
👉 "🔁" 👷, 👆 "🔁" ⏮️ 🏧/🍳 👶 👶. 👆 ✔️ ⌛ 👶 &amp; 📤 ☑ 🙍 👈 🏧/🍳 👶 👶 🏁 🍔 &amp; 🤝 👫 👆, ⚖️ ⏪, 👱 🙆 💪 ✊ 👫.
<img src="/img/async/parallel-burgers/parallel-burgers-04.png" class="illustration">
⤴️ 👆 🏧/🍳 👶 👶 😒 👟 🔙 ⏮️ 👆 🍔, ⏮️ 📏 🕰 ⌛ 👶 📤 🚪 ⏲.
<img src="/img/async/parallel-burgers/parallel-burgers-05.png" class="illustration">
👆 ✊ 👆 🍔 &amp; 🚶 🏓 ⏮️ 👆 🥰.
👆 🍴 👫, &amp; 👆 🔨. ⏹
<img src="/img/async/parallel-burgers/parallel-burgers-06.png" class="illustration">
📤 🚫 🌅 💬 ⚖️ 😏 🌅 🕰 💸 ⌛ 👶 🚪 ⏲. 👶
!!! info
🌹 🖼 <a href="https://www.instagram.com/ketrinadrawsalot" class="external-link" target="_blank">👯 🍏</a>. 👶
---
👉 😐 🔗 🍔, 👆 💻 / 📋 👶 ⏮️ 2️⃣ 🕹 (👆 &amp; 👆 🥰), 👯‍♂️ ⌛ 👶 &amp; 💡 👫 🙋 👶 "⌛ 🔛 ⏲" 👶 📏 🕰.
⏩ 🥕 🏪 ✔️ 8️⃣ 🕹 (🏧/🍳). ⏪ 🛠️ 🍔 🏪 💪 ✔️ ✔️ 🕴 2️⃣ (1️⃣ 🏧 &amp; 1️⃣ 🍳).
✋️, 🏁 💡 🚫 🏆. 👶
---
👉 🔜 🔗 🌓 📖 🍔. 👶
🌅 "🎰 👨‍❤‍👨" 🖼 👉, 🌈 🏦.
🆙 ⏳, 🏆 🏦 ✔️ 💗 🏧 👶 👶 👶 👶 👶 👶 👶 👶 &amp; 🦏 ⏸ 👶 👶 👶 👶 👶 👶 👶 👶.
🌐 🏧 🔨 🌐 👷 ⏮️ 1️⃣ 👩‍💻 ⏮️ 🎏 👶 👶 👶.
&amp; 👆 ✔️ ⌛ 👶 ⏸ 📏 🕰 ⚖️ 👆 💸 👆 🔄.
👆 🎲 🚫🔜 💚 ✊ 👆 🥰 👶 ⏮️ 👆 👷 🏦 👶.
### 🍔 🏁
👉 😐 "⏩ 🥕 🍔 ⏮️ 👆 🥰", 📤 📚 ⌛ 👶, ⚫️ ⚒ 📚 🌅 🔑 ✔️ 🛠️ ⚙️ ⏸ 👶 👶.
👉 💼 🌅 🕸 🈸.
📚, 📚 👩‍💻, ✋️ 👆 💽 ⌛ 👶 👫 🚫--👍 🔗 📨 👫 📨.
&amp; ⤴️ ⌛ 👶 🔄 📨 👟 🔙.
👉 "⌛" 👶 ⚖ ⏲, ✋️, ⚖ ⚫️ 🌐, ⚫️ 📚 ⌛ 🔚.
👈 ⚫️❔ ⚫️ ⚒ 📚 🔑 ⚙️ 🔁 ⏸ 👶 👶 📟 🕸 🔗.
👉 😇 🔀 ⚫️❔ ⚒ ✳ 🌟 (✋️ ✳ 🚫 🔗) &amp; 👈 💪 🚶 🛠️ 🇪🇸.
&amp; 👈 🎏 🎚 🎭 👆 🤚 ⏮️ **FastAPI**.
&amp; 👆 💪 ✔️ 🔁 &amp; 🔀 🎏 🕰, 👆 🤚 ↕ 🎭 🌘 🌅 💯 ✳ 🛠️ &amp; 🔛 🇷🇪 ⏮️ 🚶, ❔ ✍ 🇪🇸 🔐 🅱 <a href="https://www.techempower.com/benchmarks/#section=data-r17&hw=ph&test=query&l=zijmkf-1" class="external-link" target="_blank">(🌐 👏 💃)</a>.
### 🛠️ 👍 🌘 🔁 ❓
😆 ❗ 👈 🚫 🛐 📖.
🛠️ 🎏 🌘 🔁. &amp; ⚫️ 👻 🔛 **🎯** 😐 👈 🔌 📚 ⌛. ↩️ 👈, ⚫️ 🛎 📚 👍 🌘 🔁 🕸 🈸 🛠️. ✋️ 🚫 🌐.
, ⚖ 👈 👅, 🌈 📄 📏 📖:
&gt; 👆 ✔️ 🧹 🦏, 💩 🏠.
*😆, 👈 🎂 📖*.
---
📤 🙅‍♂ ⌛ 👶 🙆, 📚 👷 🔨, 🔛 💗 🥉 🏠.
👆 💪 ✔️ 🔄 🍔 🖼, 🥇 🏠 🧖‍♂, ⤴️ 👨‍🍳, ✋️ 👆 🚫 ⌛ 👶 🕳, 🧹 &amp; 🧹, 🔄 🚫🔜 📉 🕳.
⚫️ 🔜 ✊ 🎏 💸 🕰 🏁 ⏮️ ⚖️ 🍵 🔄 (🛠️) &amp; 👆 🔜 ✔️ ⌛ 🎏 💸 👷.
✋️ 👉 💼, 🚥 👆 💪 ✊️ 8️⃣ 👰-🏧/🍳/🔜-🧹, &amp; 🔠 1️⃣ 👫 (➕ 👆) 💪 ✊ 🏒 🏠 🧹 ⚫️, 👆 💪 🌐 👷 **🔗**, ⏮️ ➕ ℹ, &amp; 🏁 🌅 🔜.
👉 😐, 🔠 1️⃣ 🧹 (🔌 👆) 🔜 🕹, 🤸 👫 🍕 👨‍🏭.
&amp; 🏆 🛠️ 🕰 ✊ ☑ 👷 (↩️ ⌛), &amp; 👷 💻 ⌛ <abbr title="Central Processing Unit">💽</abbr>, 👫 🤙 👫 ⚠ "💽 🎁".
---
⚠ 🖼 💽 🔗 🛠️ 👜 👈 🚚 🏗 🧪 🏭.
🖼:
* **🎧** ⚖️ **🖼 🏭**.
* **💻 👓**: 🖼 ✍ 💯 🔅, 🔠 🔅 ✔️ 3️⃣ 💲 / 🎨, 🏭 👈 🛎 🚚 💻 🕳 🔛 📚 🔅, 🌐 🎏 🕰.
* **🎰 🏫**: ⚫️ 🛎 🚚 📚 "✖" &amp; "🖼" ✖. 💭 🦏 📋 ⏮️ 🔢 &amp; ✖ 🌐 👫 👯‍♂️ 🎏 🕰.
* **⏬ 🏫**: 👉 🎧-🏑 🎰 🏫,, 🎏 ✔. ⚫️ 👈 📤 🚫 👁 📋 🔢 ✖, ✋️ 🦏 ⚒ 👫, &amp; 📚 💼, 👆 ⚙️ 🎁 🕹 🏗 &amp; / ⚖️ ⚙️ 👈 🏷.
### 🛠️ ➕ 🔁: 🕸 ➕ 🎰 🏫
⏮️ **FastAPI** 👆 💪 ✊ 📈 🛠️ 👈 📶 ⚠ 🕸 🛠️ (🎏 👑 🧲 ✳).
✋️ 👆 💪 🐄 💰 🔁 &amp; 💾 (✔️ 💗 🛠️ 🏃‍♂ 🔗) **💽 🎁** ⚖ 💖 👈 🎰 🏫 ⚙️.
👈, ➕ 🙅 👐 👈 🐍 👑 🇪🇸 **💽 🧪**, 🎰 🏫 &amp; ✴️ ⏬ 🏫, ⚒ FastAPI 📶 👍 🏏 💽 🧪 / 🎰 🏫 🕸 🔗 &amp; 🈸 (👪 📚 🎏).
👀 ❔ 🏆 👉 🔁 🏭 👀 📄 🔃 [🛠️](deployment/index.md){.internal-link target=_blank}.
## `async` &amp; `await`
🏛 ⏬ 🐍 ✔️ 📶 🏋️ 🌌 🔬 🔁 📟. 👉 ⚒ ⚫️ 👀 💖 😐 "🔁" 📟 &amp; "⌛" 👆 ▶️️ 🙍.
🕐❔ 📤 🛠️ 👈 🔜 🚚 ⌛ ⏭ 🤝 🏁 &amp; ✔️ 🐕‍🦺 👉 🆕 🐍 ⚒, 👆 💪 📟 ⚫️ 💖:
```Python
burgers = await get_burgers(2)
```
🔑 📥 `await`. ⚫️ 💬 🐍 👈 ⚫️ ✔️ ⌛ ⏸ `get_burgers(2)` 🏁 🔨 🚮 👜 👶 ⏭ ♻ 🏁 `burgers`. ⏮️ 👈, 🐍 🔜 💭 👈 ⚫️ 💪 🚶 &amp; 🕳 🙆 👶 👶 👐 (💖 📨 ➕1️⃣ 📨).
`await` 👷, ⚫️ ✔️ 🔘 🔢 👈 🐕‍🦺 👉 🔀. 👈, 👆 📣 ⚫️ ⏮️ `async def`:
```Python hl_lines="1"
async def get_burgers(number: int):
# Do some asynchronous stuff to create the burgers
return burgers
```
...↩️ `def`:
```Python hl_lines="2"
# This is not asynchronous
def get_sequential_burgers(number: int):
# Do some sequential stuff to create the burgers
return burgers
```
⏮️ `async def`, 🐍 💭 👈, 🔘 👈 🔢, ⚫️ ✔️ 🤔 `await` 🧬, &amp; 👈 ⚫️ 💪 "⏸" ⏸ 🛠️ 👈 🔢 &amp; 🚶 🕳 🙆 👶 ⏭ 👟 🔙.
🕐❔ 👆 💚 🤙 `async def` 🔢, 👆 ✔️ "⌛" ⚫️. , 👉 🏆 🚫 👷:
```Python
# This won't work, because get_burgers was defined with: async def
burgers = get_burgers(2)
```
---
, 🚥 👆 ⚙️ 🗃 👈 💬 👆 👈 👆 💪 🤙 ⚫️ ⏮️ `await`, 👆 💪 ✍ *➡ 🛠️ 🔢* 👈 ⚙️ ⚫️ ⏮️ `async def`, 💖:
```Python hl_lines="2-3"
@app.get('/burgers')
async def read_burgers():
burgers = await get_burgers(2)
return burgers
```
### 🌅 📡 ℹ
👆 💪 ✔️ 👀 👈 `await` 💪 🕴 ⚙️ 🔘 🔢 🔬 ⏮️ `async def`.
✋️ 🎏 🕰, 🔢 🔬 ⏮️ `async def` ✔️ "⌛". , 🔢 ⏮️ `async def` 💪 🕴 🤙 🔘 🔢 🔬 ⏮️ `async def` 💁‍♂️.
, 🔃 🥚 &amp; 🐔, ❔ 👆 🤙 🥇 `async` 🔢 ❓
🚥 👆 👷 ⏮️ **FastAPI** 👆 🚫 ✔️ 😟 🔃 👈, ↩️ 👈 "🥇" 🔢 🔜 👆 *➡ 🛠️ 🔢*, &amp; FastAPI 🔜 💭 ❔ ▶️️ 👜.
✋️ 🚥 👆 💚 ⚙️ `async` / `await` 🍵 FastAPI, 👆 💪 ⚫️ 👍.
### ✍ 👆 👍 🔁 📟
💃 (&amp; **FastAPI**) ⚓️ 🔛 <a href="https://anyio.readthedocs.io/en/stable/" class="external-link" target="_blank">AnyIO</a>, ❔ ⚒ ⚫️ 🔗 ⏮️ 👯‍♂️ 🐍 🐩 🗃 <a href="https://docs.python.org/3/library/asyncio-task.html" class="external-link" target="_blank"></a> &amp; <a href="https://trio.readthedocs.io/en/stable/" class="external-link" target="_blank">🎻</a>.
🎯, 👆 💪 🔗 ⚙️ <a href="https://anyio.readthedocs.io/en/stable/" class="external-link" target="_blank">AnyIO</a> 👆 🏧 🛠️ ⚙️ 💼 👈 🚚 🌅 🏧 ⚓ 👆 👍 📟.
&amp; 🚥 👆 🚫 ⚙️ FastAPI, 👆 💪 ✍ 👆 👍 🔁 🈸 ⏮️ <a href="https://anyio.readthedocs.io/en/stable/" class="external-link" target="_blank">AnyIO</a> 🏆 🔗 &amp; 🤚 🚮 💰 (✅ *📊 🛠️*).
### 🎏 📨 🔁 📟
👉 👗 ⚙️ `async` &amp; `await` 📶 🆕 🇪🇸.
✋️ ⚫️ ⚒ 👷 ⏮️ 🔁 📟 📚 ⏩.
👉 🎏 ❕ (⚖️ 🌖 🌓) 🔌 ⏳ 🏛 ⏬ 🕸 (🖥 &amp; ✳).
✋️ ⏭ 👈, 🚚 🔁 📟 🌖 🏗 &amp; ⚠.
⏮️ ⏬ 🐍, 👆 💪 ✔️ ⚙️ 🧵 ⚖️ <a href="https://www.gevent.org/" class="external-link" target="_blank">🐁</a>. ✋️ 📟 🌌 🌖 🏗 🤔, ℹ, &amp; 💭 🔃.
⏮️ ⏬ ✳ / 🖥 🕸, 👆 🔜 ✔️ ⚙️ "⏲". ❔ ↘️ <a href="http://callbackhell.com/" class="external-link" target="_blank">⏲ 🔥😈</a>.
## 🔁
**🔁** 📶 🎀 ⚖ 👜 📨 `async def` 🔢. 🐍 💭 👈 ⚫️ 🕳 💖 🔢 👈 ⚫️ 💪 ▶️ &amp; 👈 ⚫️ 🔜 🔚 ☝, ✋️ 👈 ⚫️ 5️⃣📆 ⏸ ⏸ 🔘 💁‍♂️, 🕐❔ 📤 `await` 🔘 ⚫️.
✋️ 🌐 👉 🛠️ ⚙️ 🔁 📟 ⏮️ `async` &amp; `await` 📚 🕰 🔬 ⚙️ "🔁". ⚫️ ⭐ 👑 🔑 ⚒ 🚶, "🔁".
## 🏁
➡️ 👀 🎏 🔤 ⚪️➡️ 🔛:
> 🏛 ⏬ 🐍 ✔️ 🐕‍🦺 **"🔁 📟"** ⚙️ 🕳 🤙 **"🔁"**, ⏮️ **`async` &amp; `await`** ❕.
👈 🔜 ⚒ 🌅 🔑 🔜. 👶
🌐 👈 ⚫️❔ 🏋️ FastAPI (🔘 💃) &amp; ⚫️❔ ⚒ ⚫️ ✔️ ✅ 🎆 🎭.
## 📶 📡 ℹ
!!! warning
👆 💪 🎲 🚶 👉.
👉 📶 📡 ℹ ❔ **FastAPI** 👷 🔘.
🚥 👆 ✔️ 📡 💡 (🈶-🏋, 🧵, 🍫, ♒️.) &amp; 😟 🔃 ❔ FastAPI 🍵 `async def` 🆚 😐 `def`, 🚶 ⤴️.
### ➡ 🛠️ 🔢
🕐❔ 👆 📣 *➡ 🛠️ 🔢* ⏮️ 😐 `def` ↩️ `async def`, ⚫️ 🏃 🔢 🧵 👈 ⤴️ ⌛, ↩️ ➖ 🤙 🔗 (⚫️ 🔜 🍫 💽).
🚥 👆 👟 ⚪️➡️ ➕1️⃣ 🔁 🛠️ 👈 🔨 🚫 👷 🌌 🔬 🔛 &amp; 👆 ⚙️ ⚖ 🙃 📊-🕴 *➡ 🛠️ 🔢* ⏮️ ✅ `def` 🤪 🎭 📈 (🔃 1️⃣0️⃣0️⃣ 💓), 🙏 🗒 👈 **FastAPI** ⭐ 🔜 🔄. 👫 💼, ⚫️ 👻 ⚙️ `async def` 🚥 👆 *➡ 🛠️ 🔢* ⚙️ 📟 👈 🎭 🚧 <abbr title="Input/Output: disk reading or writing, network communications.">👤/🅾</abbr>.
, 👯‍♂️ ⚠, 🤞 👈 **FastAPI** 🔜 [](/#performance){.internal-link target=_blank} 🌘 (⚖️ 🌘 ⭐) 👆 ⏮️ 🛠️.
### 🔗
🎏 ✔ [🔗](/tutorial/dependencies/index.md){.internal-link target=_blank}. 🚥 🔗 🐩 `def` 🔢 ↩️ `async def`, ⚫️ 🏃 🔢 🧵.
### 🎧-🔗
👆 💪 ✔️ 💗 🔗 &amp; [🎧-🔗](/tutorial/dependencies/sub-dependencies.md){.internal-link target=_blank} 🚫 🔠 🎏 (🔢 🔢 🔑), 👫 💪 ✍ ⏮️ `async def` &amp; ⏮️ 😐 `def`. ⚫️ 🔜 👷, &amp; 🕐 ✍ ⏮️ 😐 `def` 🔜 🤙 🔛 🔢 🧵 (⚪️➡️ 🧵) ↩️ ➖ "⌛".
### 🎏 🚙 🔢
🙆 🎏 🚙 🔢 👈 👆 🤙 🔗 💪 ✍ ⏮️ 😐 `def` ⚖️ `async def` &amp; FastAPI 🏆 🚫 📉 🌌 👆 🤙 ⚫️.
👉 🔅 🔢 👈 FastAPI 🤙 👆: *➡ 🛠️ 🔢* &amp; 🔗.
🚥 👆 🚙 🔢 😐 🔢 ⏮️ `def`, ⚫️ 🔜 🤙 🔗 (👆 ✍ ⚫️ 👆 📟), 🚫 🧵, 🚥 🔢 ✍ ⏮️ `async def` ⤴️ 👆 🔜 `await` 👈 🔢 🕐❔ 👆 🤙 ⚫️ 👆 📟.
---
🔄, 👉 📶 📡 ℹ 👈 🔜 🎲 ⚠ 🚥 👆 👟 🔎 👫.
⏪, 👆 🔜 👍 ⏮️ 📄 ⚪️➡️ 📄 🔛: <a href="#in-a-hurry">🏃 ❓</a>.

34
docs/em/docs/benchmarks.md

@ -0,0 +1,34 @@
# 📇
🔬 🇸🇲 📇 🎦 **FastAPI** 🈸 🏃‍♂ 🔽 Uvicorn <a href="https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7" class="external-link" target="_blank">1️⃣ ⏩ 🐍 🛠️ 💪</a>, 🕴 🔛 💃 &amp; Uvicorn 👫 (⚙️ 🔘 FastAPI). (*)
✋️ 🕐❔ ✅ 📇 &amp; 🔺 👆 🔜 ✔️ 📄 🤯.
## 📇 &amp; 🚅
🕐❔ 👆 ✅ 📇, ⚫️ ⚠ 👀 📚 🧰 🎏 🆎 🔬 🌓.
🎯, 👀 Uvicorn, 💃 &amp; FastAPI 🔬 👯‍♂️ (👪 📚 🎏 🧰).
🙅 ⚠ ❎ 🧰, 👍 🎭 ⚫️ 🔜 🤚. &amp; 🏆 📇 🚫 💯 🌖 ⚒ 🚚 🧰.
🔗 💖:
* **Uvicorn**: 🔫 💽
* **💃**: (⚙️ Uvicorn) 🕸 🕸
* **FastAPI**: (⚙️ 💃) 🛠️ 🕸 ⏮️ 📚 🌖 ⚒ 🏗 🔗, ⏮️ 💽 🔬, ♒️.
* **Uvicorn**:
* 🔜 ✔️ 🏆 🎭, ⚫️ 🚫 ✔️ 🌅 ➕ 📟 ↖️ ⚪️➡️ 💽 ⚫️.
* 👆 🚫🔜 ✍ 🈸 Uvicorn 🔗. 👈 🔜 ⛓ 👈 👆 📟 🔜 ✔️ 🔌 🌖 ⚖️ 🌘, 🌘, 🌐 📟 🚚 💃 (⚖️ **FastAPI**). &amp; 🚥 👆 👈, 👆 🏁 🈸 🔜 ✔️ 🎏 🌥 ✔️ ⚙️ 🛠️ &amp; 📉 👆 📱 📟 &amp; 🐛.
* 🚥 👆 ⚖ Uvicorn, 🔬 ⚫️ 🛡 👸, Hypercorn, ✳, ♒️. 🈸 💽.
* **💃**:
* 🔜 ✔️ ⏭ 🏆 🎭, ⏮️ Uvicorn. 👐, 💃 ⚙️ Uvicorn 🏃. , ⚫️ 🎲 💪 🕴 🤚 "🐌" 🌘 Uvicorn ✔️ 🛠️ 🌅 📟.
* ✋️ ⚫️ 🚚 👆 🧰 🏗 🙅 🕸 🈸, ⏮️ 🕹 ⚓️ 🔛 ➡, ♒️.
* 🚥 👆 ⚖ 💃, 🔬 ⚫️ 🛡 🤣, 🏺, ✳, ♒️. 🕸 🛠️ (⚖️ 🕸).
* **FastAPI**:
* 🎏 🌌 👈 💃 ⚙️ Uvicorn &amp; 🚫🔜 ⏩ 🌘 ⚫️, **FastAPI** ⚙️ 💃, ⚫️ 🚫🔜 ⏩ 🌘 ⚫️.
* FastAPI 🚚 🌅 ⚒ 🔛 🔝 💃. ⚒ 👈 👆 🌖 🕧 💪 🕐❔ 🏗 🔗, 💖 💽 🔬 &amp; 🛠️. &amp; ⚙️ ⚫️, 👆 🤚 🏧 🧾 🆓 (🏧 🧾 🚫 🚮 🌥 🏃‍♂ 🈸, ⚫️ 🏗 🔛 🕴).
* 🚥 👆 🚫 ⚙️ FastAPI &amp; ⚙️ 💃 🔗 (⚖️ ➕1️⃣ 🧰, 💖 🤣, 🏺, 🆘, ♒️) 👆 🔜 ✔️ 🛠️ 🌐 💽 🔬 &amp; 🛠️ 👆. , 👆 🏁 🈸 🔜 ✔️ 🎏 🌥 🚥 ⚫️ 🏗 ⚙️ FastAPI. &amp; 📚 💼, 👉 💽 🔬 &amp; 🛠️ 🦏 💸 📟 ✍ 🈸.
* , ⚙️ FastAPI 👆 ♻ 🛠️ 🕰, 🐛, ⏸ 📟, &amp; 👆 🔜 🎲 🤚 🎏 🎭 (⚖️ 👍) 👆 🔜 🚥 👆 🚫 ⚙️ ⚫️ (👆 🔜 ✔️ 🛠️ ⚫️ 🌐 👆 📟).
* 🚥 👆 ⚖ FastAPI, 🔬 ⚫️ 🛡 🕸 🈸 🛠️ (⚖️ ⚒ 🧰) 👈 🚚 💽 🔬, 🛠️ &amp; 🧾, 💖 🏺-apispec, NestJS, ♨, ♒️. 🛠️ ⏮️ 🛠️ 🏧 💽 🔬, 🛠️ &amp; 🧾.

465
docs/em/docs/contributing.md

@ -0,0 +1,465 @@
# 🛠️ - 📉
🥇, 👆 💪 💚 👀 🔰 🌌 [ℹ FastAPI &amp; 🤚 ℹ](help-fastapi.md){.internal-link target=_blank}.
## 🛠️
🚥 👆 ⏪ 🖖 🗃 &amp; 👆 💭 👈 👆 💪 ⏬ 🤿 📟, 📥 📄 ⚒ 🆙 👆 🌐.
### 🕹 🌐 ⏮️ `venv`
👆 💪 ✍ 🕹 🌐 📁 ⚙️ 🐍 `venv` 🕹:
<div class="termy">
```console
$ python -m venv env
```
</div>
👈 🔜 ✍ 📁 `./env/` ⏮️ 🐍 💱 &amp; ⤴️ 👆 🔜 💪 ❎ 📦 👈 ❎ 🌐.
### 🔓 🌐
🔓 🆕 🌐 ⏮️:
=== "💾, 🇸🇻"
<div class="termy">
```console
$ source ./env/bin/activate
```
</div>
=== "🚪 📋"
<div class="termy">
```console
$ .\env\Scripts\Activate.ps1
```
</div>
=== "🚪 🎉"
⚖️ 🚥 👆 ⚙️ 🎉 🖥 (✅ <a href="https://gitforwindows.org/" class="external-link" target="_blank">🐛 🎉</a>):
<div class="termy">
```console
$ source ./env/Scripts/activate
```
</div>
✅ ⚫️ 👷, ⚙️:
=== "💾, 🇸🇻, 🚪 🎉"
<div class="termy">
```console
$ which pip
some/directory/fastapi/env/bin/pip
```
</div>
=== "🚪 📋"
<div class="termy">
```console
$ Get-Command pip
some/directory/fastapi/env/bin/pip
```
</div>
🚥 ⚫️ 🎦 `pip` 💱 `env/bin/pip` ⤴️ ⚫️ 👷. 👶
⚒ 💭 👆 ✔️ 📰 🐖 ⏬ 🔛 👆 🕹 🌐 ❎ ❌ 🔛 ⏭ 📶:
<div class="termy">
```console
$ python -m pip install --upgrade pip
---> 100%
```
</div>
!!! tip
🔠 🕰 👆 ❎ 🆕 📦 ⏮️ `pip` 🔽 👈 🌐, 🔓 🌐 🔄.
👉 ⚒ 💭 👈 🚥 👆 ⚙️ 📶 📋 ❎ 👈 📦, 👆 ⚙️ 1️⃣ ⚪️➡️ 👆 🇧🇿 🌐 &amp; 🚫 🙆 🎏 👈 💪 ❎ 🌐.
### 🐖
⏮️ 🔓 🌐 🔬 🔛:
<div class="termy">
```console
$ pip install -r requirements.txt
---> 100%
```
</div>
⚫️ 🔜 ❎ 🌐 🔗 &amp; 👆 🇧🇿 FastAPI 👆 🇧🇿 🌐.
#### ⚙️ 👆 🇧🇿 FastAPI
🚥 👆 ✍ 🐍 📁 👈 🗄 &amp; ⚙️ FastAPI, &amp; 🏃 ⚫️ ⏮️ 🐍 ⚪️➡️ 👆 🇧🇿 🌐, ⚫️ 🔜 ⚙️ 👆 🇧🇿 FastAPI ℹ 📟.
&amp; 🚥 👆 ℹ 👈 🇧🇿 FastAPI ℹ 📟, ⚫️ ❎ ⏮️ `-e`, 🕐❔ 👆 🏃 👈 🐍 📁 🔄, ⚫️ 🔜 ⚙️ 🍋 ⏬ FastAPI 👆 ✍.
👈 🌌, 👆 🚫 ✔️ "❎" 👆 🇧🇿 ⏬ 💪 💯 🔠 🔀.
### 📁
📤 ✍ 👈 👆 💪 🏃 👈 🔜 📁 &amp; 🧹 🌐 👆 📟:
<div class="termy">
```console
$ bash scripts/format.sh
```
</div>
⚫️ 🔜 🚘-😇 🌐 👆 🗄.
⚫️ 😇 👫 ☑, 👆 💪 ✔️ FastAPI ❎ 🌐 👆 🌐, ⏮️ 📋 📄 🔛 ⚙️ `-e`.
## 🩺
🥇, ⚒ 💭 👆 ⚒ 🆙 👆 🌐 🔬 🔛, 👈 🔜 ❎ 🌐 📄.
🧾 ⚙️ <a href="https://www.mkdocs.org/" class="external-link" target="_blank"></a>.
&amp; 📤 ➕ 🧰/✍ 🥉 🍵 ✍ `./scripts/docs.py`.
!!! tip
👆 🚫 💪 👀 📟 `./scripts/docs.py`, 👆 ⚙️ ⚫️ 📋 ⏸.
🌐 🧾 ✍ 📁 📁 `./docs/en/`.
📚 🔰 ✔️ 🍫 📟.
🌅 💼, 👫 🍫 📟 ☑ 🏁 🈸 👈 💪 🏃.
👐, 👈 🍫 📟 🚫 ✍ 🔘 ✍, 👫 🐍 📁 `./docs_src/` 📁.
&amp; 👈 🐍 📁 🔌/💉 🧾 🕐❔ 🏭 🕸.
### 🩺 💯
🏆 💯 🤙 🏃 🛡 🖼 ℹ 📁 🧾.
👉 ℹ ⚒ 💭 👈:
* 🧾 🆙 📅.
* 🧾 🖼 💪 🏃.
* 🌅 ⚒ 📔 🧾, 🚚 💯 💰.
⏮️ 🇧🇿 🛠️, 📤 ✍ 👈 🏗 🕸 &amp; ✅ 🙆 🔀, 🖖-🔫:
<div class="termy">
```console
$ python ./scripts/docs.py live
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
<span style="color: green;">[INFO]</span> Start watching changes
<span style="color: green;">[INFO]</span> Start detecting changes
```
</div>
⚫️ 🔜 🍦 🧾 🔛 `http://127.0.0.1:8008`.
👈 🌌, 👆 💪 ✍ 🧾/ℹ 📁 &amp; 👀 🔀 🖖.
#### 🏎 ✳ (📦)
👩‍🌾 📥 🎦 👆 ❔ ⚙️ ✍ `./scripts/docs.py` ⏮️ `python` 📋 🔗.
✋️ 👆 💪 ⚙️ <a href="https://typer.tiangolo.com/typer-cli/" class="external-link" target="_blank">🏎 ✳</a>, &amp; 👆 🔜 🤚 ✍ 👆 📶 📋 ⏮️ ❎ 🛠️.
🚥 👆 ❎ 🏎 ✳, 👆 💪 ❎ 🛠️ ⏮️:
<div class="termy">
```console
$ typer --install-completion
zsh completion installed in /home/user/.bashrc.
Completion will take effect once you restart the terminal.
```
</div>
### 📱 &amp; 🩺 🎏 🕰
🚥 👆 🏃 🖼 ⏮️, ✅:
<div class="termy">
```console
$ uvicorn tutorial001:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
Uvicorn 🔢 🔜 ⚙️ ⛴ `8000`, 🧾 🔛 ⛴ `8008` 🏆 🚫 ⚔.
### ✍
ℹ ⏮️ ✍ 📶 🌅 👍 ❗ &amp; ⚫️ 💪 🚫 🔨 🍵 ℹ ⚪️➡️ 👪. 👶 👶
📥 📶 ℹ ⏮️ ✍.
#### 💁‍♂ &amp; 📄
* ✅ ⏳ <a href="https://github.com/tiangolo/fastapi/pulls" class="external-link" target="_blank">♻ 🚲 📨</a> 👆 🇪🇸 &amp; 🚮 📄 ✔ 🔀 ⚖️ ✔ 👫.
!!! tip
👆 💪 <a href="https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request" class="external-link" target="_blank">🚮 🏤 ⏮️ 🔀 🔑</a> ♻ 🚲 📨.
✅ 🩺 🔃 <a href="https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews" class="external-link" target="_blank">❎ 🚲 📨 📄</a> ✔ ⚫️ ⚖️ 📨 🔀.
* ✅ <a href="https://github.com/tiangolo/fastapi/issues" class="external-link" target="_blank"></a> 👀 🚥 📤 1️⃣ 🛠️ ✍ 👆 🇪🇸.
* 🚮 👁 🚲 📨 📍 📃 💬. 👈 🔜 ⚒ ⚫️ 🌅 ⏩ 🎏 📄 ⚫️.
🇪🇸 👤 🚫 💬, 👤 🔜 ⌛ 📚 🎏 📄 ✍ ⏭ 🔗.
* 👆 💪 ✅ 🚥 📤 ✍ 👆 🇪🇸 &amp; 🚮 📄 👫, 👈 🔜 ℹ 👤 💭 👈 ✍ ☑ &amp; 👤 💪 🔗 ⚫️.
* ⚙️ 🎏 🐍 🖼 &amp; 🕴 💬 ✍ 🩺. 👆 🚫 ✔️ 🔀 🕳 👉 👷.
* ⚙️ 🎏 🖼, 📁 📛, &amp; 🔗. 👆 🚫 ✔️ 🔀 🕳 ⚫️ 👷.
* ✅ 2️⃣-🔤 📟 🇪🇸 👆 💚 💬 👆 💪 ⚙️ 🏓 <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" class="external-link" target="_blank">📇 💾 6️⃣3️⃣9️⃣-1️⃣ 📟</a>.
#### ♻ 🇪🇸
➡️ 💬 👆 💚 💬 📃 🇪🇸 👈 ⏪ ✔️ ✍ 📃, 💖 🇪🇸.
💼 🇪🇸, 2️⃣-🔤 📟 `es`. , 📁 🇪🇸 ✍ 🔎 `docs/es/`.
!!! tip
👑 ("🛂") 🇪🇸 🇪🇸, 🔎 `docs/en/`.
🔜 🏃 🖖 💽 🩺 🇪🇸:
<div class="termy">
```console
// Use the command "live" and pass the language code as a CLI argument
$ python ./scripts/docs.py live es
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
<span style="color: green;">[INFO]</span> Start watching changes
<span style="color: green;">[INFO]</span> Start detecting changes
```
</div>
🔜 👆 💪 🚶 <a href="http://127.0.0.1:8008" class="external-link" target="_blank">http://127.0.0.1:8008</a> &amp; 👀 👆 🔀 🖖.
🚥 👆 👀 FastAPI 🩺 🕸, 👆 🔜 👀 👈 🔠 🇪🇸 ✔️ 🌐 📃. ✋️ 📃 🚫 💬 &amp; ✔️ 📨 🔃 ❌ ✍.
✋️ 🕐❔ 👆 🏃 ⚫️ 🌐 💖 👉, 👆 🔜 🕴 👀 📃 👈 ⏪ 💬.
🔜 ➡️ 💬 👈 👆 💚 🚮 ✍ 📄 [](features.md){.internal-link target=_blank}.
* 📁 📁:
```
docs/en/docs/features.md
```
* 📋 ⚫️ ⚫️❔ 🎏 🗺 ✋️ 🇪🇸 👆 💚 💬, ✅:
```
docs/es/docs/features.md
```
!!! tip
👀 👈 🕴 🔀 ➡ &amp; 📁 📛 🇪🇸 📟, ⚪️➡️ `en` `es`.
* 🔜 📂 ⬜ 📁 📁 🇪🇸:
```
docs/en/mkdocs.yml
```
* 🔎 🥉 🌐❔ 👈 `docs/features.md` 🔎 📁 📁. 👱 💖:
```YAML hl_lines="8"
site_name: FastAPI
# More stuff
nav:
- FastAPI: index.md
- Languages:
- en: /
- es: /es/
- features.md
```
* 📂 ⬜ 📁 📁 🇪🇸 👆 ✍, ✅:
```
docs/es/mkdocs.yml
```
* 🚮 ⚫️ 📤 ☑ 🎏 🗺 ⚫️ 🇪🇸, ✅:
```YAML hl_lines="8"
site_name: FastAPI
# More stuff
nav:
- FastAPI: index.md
- Languages:
- en: /
- es: /es/
- features.md
```
⚒ 💭 👈 🚥 📤 🎏 ⛔, 🆕 ⛔ ⏮️ 👆 ✍ ⚫️❔ 🎏 ✔ 🇪🇸 ⏬.
🚥 👆 🚶 👆 🖥 👆 🔜 👀 👈 🔜 🩺 🎦 👆 🆕 📄. 👶
🔜 👆 💪 💬 ⚫️ 🌐 &amp; 👀 ❔ ⚫️ 👀 👆 🖊 📁.
#### 🆕 🇪🇸
➡️ 💬 👈 👆 💚 🚮 ✍ 🇪🇸 👈 🚫 💬, 🚫 📃.
➡️ 💬 👆 💚 🚮 ✍ 🇭🇹, &amp; ⚫️ 🚫 📤 🩺.
✅ 🔗 ⚪️➡️ 🔛, 📟 "🇭🇹" `ht`.
⏭ 🔁 🏃 ✍ 🏗 🆕 ✍ 📁:
<div class="termy">
```console
// Use the command new-lang, pass the language code as a CLI argument
$ python ./scripts/docs.py new-lang ht
Successfully initialized: docs/ht
Updating ht
Updating en
```
</div>
🔜 👆 💪 ✅ 👆 📟 👨‍🎨 ⏳ ✍ 📁 `docs/ht/`.
!!! tip
✍ 🥇 🚲 📨 ⏮️ 👉, ⚒ 🆙 📳 🆕 🇪🇸, ⏭ ❎ ✍.
👈 🌌 🎏 💪 ℹ ⏮️ 🎏 📃 ⏪ 👆 👷 🔛 🥇 🕐. 👶
▶️ ✍ 👑 📃, `docs/ht/index.md`.
⤴️ 👆 💪 😣 ⏮️ ⏮️ 👩‍🌾, "♻ 🇪🇸".
##### 🆕 🇪🇸 🚫 🐕‍🦺
🚥 🕐❔ 🏃‍♂ 🖖 💽 ✍ 👆 🤚 ❌ 🔃 🇪🇸 🚫 ➖ 🐕‍🦺, 🕳 💖:
```
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: partials/language/xx.html
```
👈 ⛓ 👈 🎢 🚫 🐕‍🦺 👈 🇪🇸 (👉 💼, ⏮️ ❌ 2️⃣-🔤 📟 `xx`).
✋️ 🚫 😟, 👆 💪 ⚒ 🎢 🇪🇸 🇪🇸 &amp; ⤴️ 💬 🎚 🩺.
🚥 👆 💪 👈, ✍ `mkdocs.yml` 👆 🆕 🇪🇸, ⚫️ 🔜 ✔️ 🕳 💖:
```YAML hl_lines="5"
site_name: FastAPI
# More stuff
theme:
# More stuff
language: xx
```
🔀 👈 🇪🇸 ⚪️➡️ `xx` (⚪️➡️ 👆 🇪🇸 📟) `en`.
⤴️ 👆 💪 ▶️ 🖖 💽 🔄.
#### 🎮 🏁
🕐❔ 👆 ⚙️ ✍ `./scripts/docs.py` ⏮️ `live` 📋 ⚫️ 🕴 🎦 📁 &amp; ✍ 💪 ⏮️ 🇪🇸.
✋️ 🕐 👆 🔨, 👆 💪 💯 ⚫️ 🌐 ⚫️ 🔜 👀 💳.
👈, 🥇 🏗 🌐 🩺:
<div class="termy">
```console
// Use the command "build-all", this will take a bit
$ python ./scripts/docs.py build-all
Updating es
Updating en
Building docs for: en
Building docs for: es
Successfully built docs for: es
Copying en index.md to README.md
```
</div>
👈 🏗 🌐 🩺 `./docs_build/` 🔠 🇪🇸. 👉 🔌 ❎ 🙆 📁 ⏮️ ❌ ✍, ⏮️ 🗒 💬 👈 "👉 📁 🚫 ✔️ ✍". ✋️ 👆 🚫 ✔️ 🕳 ⏮️ 👈 📁.
⤴️ ⚫️ 🏗 🌐 👈 🔬 ⬜ 🕸 🔠 🇪🇸, 🌀 👫, &amp; 🏗 🏁 🔢 `./site/`.
⤴️ 👆 💪 🍦 👈 ⏮️ 📋 `serve`:
<div class="termy">
```console
// Use the command "serve" after running "build-all"
$ python ./scripts/docs.py serve
Warning: this is a very simple server. For development, use mkdocs serve instead.
This is here only to preview a site with translations already built.
Make sure you run the build-all command first.
Serving at: http://127.0.0.1:8008
```
</div>
## 💯
📤 ✍ 👈 👆 💪 🏃 🌐 💯 🌐 📟 &amp; 🏗 💰 📄 🕸:
<div class="termy">
```console
$ bash scripts/test-cov-html.sh
```
</div>
👉 📋 🏗 📁 `./htmlcov/`, 🚥 👆 📂 📁 `./htmlcov/index.html` 👆 🖥, 👆 💪 🔬 🖥 🇹🇼 📟 👈 📔 💯, &amp; 👀 🚥 📤 🙆 🇹🇼 ❌.

311
docs/em/docs/deployment/concepts.md

@ -0,0 +1,311 @@
# 🛠️ 🔧
🕐❔ 🛠️ **FastAPI** 🈸, ⚖️ 🤙, 🙆 🆎 🕸 🛠️, 📤 📚 🔧 👈 👆 🎲 💅 🔃, &amp; ⚙️ 👫 👆 💪 🔎 **🏆 ☑** 🌌 **🛠️ 👆 🈸**.
⚠ 🔧:
* 💂‍♂ - 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* 🧬 (🔢 🛠️ 🏃)
* 💾
* ⏮️ 🔁 ⏭ ▶️
👥 🔜 👀 ❔ 👫 🔜 📉 **🛠️**.
🔚, 🏆 🎯 💪 **🍦 👆 🛠️ 👩‍💻** 🌌 👈 **🔐**, **❎ 📉**, &amp; ⚙️ **📊 ℹ** (🖼 🛰 💽/🕹 🎰) ♻ 💪. 👶
👤 🔜 💬 👆 🍖 🌖 🔃 👫 **🔧** 📥, &amp; 👈 🔜 🤞 🤝 👆 **🤔** 👆 🔜 💪 💭 ❔ 🛠️ 👆 🛠️ 📶 🎏 🌐, 🎲 **🔮** 🕐 👈 🚫 🔀.
🤔 👫 🔧, 👆 🔜 💪 **🔬 &amp; 🔧** 🏆 🌌 🛠️ **👆 👍 🔗**.
⏭ 📃, 👤 🔜 🤝 👆 🌅 **🧱 🍮** 🛠️ FastAPI 🈸.
✋️ 🔜, ➡️ ✅ 👉 ⚠ **⚛ 💭**. 👫 🔧 ✔ 🙆 🎏 🆎 🕸 🛠️. 👶
## 💂‍♂ - 🇺🇸🔍
[⏮️ 📃 🔃 🇺🇸🔍](./https.md){.internal-link target=_blank} 👥 🇭🇲 🔃 ❔ 🇺🇸🔍 🚚 🔐 👆 🛠️.
👥 👀 👈 🇺🇸🔍 🛎 🚚 🦲 **🔢** 👆 🈸 💽, **🤝 ❎ 🗳**.
&amp; 📤 ✔️ 🕳 🈚 **♻ 🇺🇸🔍 📄**, ⚫️ 💪 🎏 🦲 ⚖️ ⚫️ 💪 🕳 🎏.
### 🖼 🧰 🇺🇸🔍
🧰 👆 💪 ⚙️ 🤝 ❎ 🗳:
* Traefik
* 🔁 🍵 📄 🔕 👶
* 📥
* 🔁 🍵 📄 🔕 👶
* 👌
* ⏮️ 🔢 🦲 💖 Certbot 📄 🔕
* ✳
* ⏮️ 🔢 🦲 💖 Certbot 📄 🔕
* Kubernete ⏮️ 🚧 🕹 💖 👌
* ⏮️ 🔢 🦲 💖 🛂-👨‍💼 📄 🔕
* 🍵 🔘 ☁ 🐕‍🦺 🍕 👫 🐕‍🦺 (✍ 🔛 👶)
➕1️⃣ 🎛 👈 👆 💪 ⚙️ **☁ 🐕‍🦺** 👈 🔨 🌖 👷 ✅ ⚒ 🆙 🇺🇸🔍. ⚫️ 💪 ✔️ 🚫 ⚖️ 🈚 👆 🌅, ♒️. ✋️ 👈 💼, 👆 🚫🔜 ✔️ ⚒ 🆙 🤝 ❎ 🗳 👆.
👤 🔜 🎦 👆 🧱 🖼 ⏭ 📃.
---
⤴️ ⏭ 🔧 🤔 🌐 🔃 📋 🏃 👆 ☑ 🛠️ (✅ Uvicorn).
## 📋 &amp; 🛠️
👥 🔜 💬 📚 🔃 🏃 "**🛠️**", ⚫️ ⚠ ✔️ ☯ 🔃 ⚫️❔ ⚫️ ⛓, &amp; ⚫️❔ 🔺 ⏮️ 🔤 "**📋**".
### ⚫️❔ 📋
🔤 **📋** 🛎 ⚙️ 🔬 📚 👜:
* **📟** 👈 👆 ✍, **🐍 📁**.
* **📁** 👈 💪 **🛠️** 🏃‍♂ ⚙️, 🖼: `python`, `python.exe` ⚖️ `uvicorn`.
* 🎯 📋 ⏪ ⚫️ **🏃‍♂** 🔛 🏗 ⚙️, ⚙️ 💽, &amp; ♻ 👜 🔛 💾. 👉 🤙 **🛠️**.
### ⚫️❔ 🛠️
🔤 **🛠️** 🛎 ⚙️ 🌖 🎯 🌌, 🕴 🔗 👜 👈 🏃 🏃‍♂ ⚙️ (💖 🏁 ☝ 🔛):
* 🎯 📋 ⏪ ⚫️ **🏃‍♂** 🔛 🏃‍♂ ⚙️.
* 👉 🚫 🔗 📁, 🚫 📟, ⚫️ 🔗 **🎯** 👜 👈 ➖ **🛠️** &amp; 🔄 🏃‍♂ ⚙️.
* 🙆 📋, 🙆 📟, **💪 🕴 👜** 🕐❔ ⚫️ ➖ **🛠️**. , 🕐❔ 📤 **🛠️ 🏃**.
* 🛠️ 💪 **❎** (⚖️ "💥") 👆, ⚖️ 🏃‍♂ ⚙️. 👈 ☝, ⚫️ ⛔️ 🏃/➖ 🛠️, &amp; ⚫️ 💪 **🙅‍♂ 📏 👜**.
* 🔠 🈸 👈 👆 ✔️ 🏃 🔛 👆 💻 ✔️ 🛠️ ⛅ ⚫️, 🔠 🏃‍♂ 📋, 🔠 🚪, ♒️. &amp; 📤 🛎 📚 🛠️ 🏃 **🎏 🕰** ⏪ 💻 🔛.
* 📤 💪 **💗 🛠️** **🎏 📋** 🏃 🎏 🕰.
🚥 👆 ✅ 👅 "📋 👨‍💼" ⚖️ "⚙️ 🖥" (⚖️ 🎏 🧰) 👆 🏃‍♂ ⚙️, 👆 🔜 💪 👀 📚 👈 🛠️ 🏃‍♂.
&amp; , 🖼, 👆 🔜 🎲 👀 👈 📤 💗 🛠️ 🏃 🎏 🖥 📋 (🦎, 💄, 📐, ♒️). 👫 🛎 🏃 1️⃣ 🛠️ 📍 📑, ➕ 🎏 ➕ 🛠️.
<img class="shadow" src="/img/deployment/concepts/image01.png">
---
🔜 👈 👥 💭 🔺 🖖 ⚖ **🛠️** &amp; **📋**, ➡️ 😣 💬 🔃 🛠️.
## 🏃‍♂ 🔛 🕴
🌅 💼, 🕐❔ 👆 ✍ 🕸 🛠️, 👆 💚 ⚫️ **🕧 🏃‍♂**, ➡, 👈 👆 👩‍💻 💪 🕧 🔐 ⚫️. 👉 ↗️, 🚥 👆 ✔️ 🎯 🤔 ⚫️❔ 👆 💚 ⚫️ 🏃 🕴 🎯 ⚠, ✋️ 🌅 🕰 👆 💚 ⚫️ 🕧 🏃‍♂ &amp; **💪**.
### 🛰 💽
🕐❔ 👆 ⚒ 🆙 🛰 💽 (☁ 💽, 🕹 🎰, ♒️.) 🙅 👜 👆 💪 🏃 Uvicorn (⚖️ 🎏) ❎, 🎏 🌌 👆 🕐❔ 🛠️ 🌐.
&amp; ⚫️ 🔜 👷 &amp; 🔜 ⚠ **⏮️ 🛠️**.
✋️ 🚥 👆 🔗 💽 💸, **🏃‍♂ 🛠️** 🔜 🎲 ☠️.
&amp; 🚥 💽 ⏏ (🖼 ⏮️ ℹ, ⚖️ 🛠️ ⚪️➡️ ☁ 🐕‍🦺) 👆 🎲 **🏆 🚫 👀 ⚫️**. &amp; ↩️ 👈, 👆 🏆 🚫 💭 👈 👆 ✔️ ⏏ 🛠️ ❎. , 👆 🛠️ 🔜 🚧 ☠️. 👶
### 🏃 🔁 🔛 🕴
🏢, 👆 🔜 🎲 💚 💽 📋 (✅ Uvicorn) ▶️ 🔁 🔛 💽 🕴, &amp; 🍵 💪 🙆 **🗿 🏥**, ✔️ 🛠️ 🕧 🏃 ⏮️ 👆 🛠️ (✅ Uvicorn 🏃‍♂ 👆 FastAPI 📱).
### 🎏 📋
🏆 👉, 👆 🔜 🛎 ✔️ **🎏 📋** 👈 🔜 ⚒ 💭 👆 🈸 🏃 🔛 🕴. &amp; 📚 💼, ⚫️ 🔜 ⚒ 💭 🎏 🦲 ⚖️ 🈸 🏃, 🖼, 💽.
### 🖼 🧰 🏃 🕴
🖼 🧰 👈 💪 👉 👨‍🏭:
* ☁
* Kubernete
* ☁ ✍
* ☁ 🐝 📳
* ✳
* 👨‍💻
* 🍵 🔘 ☁ 🐕‍🦺 🍕 👫 🐕‍🦺
* 🎏...
👤 🔜 🤝 👆 🌅 🧱 🖼 ⏭ 📃.
## ⏏
🎏 ⚒ 💭 👆 🈸 🏃 🔛 🕴, 👆 🎲 💚 ⚒ 💭 ⚫️ **⏏** ⏮️ ❌.
### 👥 ⚒ ❌
👥, 🗿, ⚒ **❌**, 🌐 🕰. 🖥 🌖 *🕧* ✔️ **🐛** 🕵‍♂ 🎏 🥉. 👶
&amp; 👥 👩‍💻 🚧 📉 📟 👥 🔎 👈 🐛 &amp; 👥 🛠️ 🆕 ⚒ (🎲 ❎ 🆕 🐛 💁‍♂️ 👶).
### 🤪 ❌ 🔁 🍵
🕐❔ 🏗 🕸 🔗 ⏮️ FastAPI, 🚥 📤 ❌ 👆 📟, FastAPI 🔜 🛎 🔌 ⚫️ 👁 📨 👈 ⏲ ❌. 🛡
👩‍💻 🔜 🤚 **5️⃣0️⃣0️⃣ 🔗 💽 ❌** 👈 📨, ✋️ 🈸 🔜 😣 👷 ⏭ 📨 ↩️ 💥 🍕.
### 🦏 ❌ - 💥
👐, 📤 5️⃣📆 💼 🌐❔ 👥 ✍ 📟 👈 **💥 🎂 🈸** ⚒ Uvicorn &amp; 🐍 💥. 👶
&amp; , 👆 🔜 🎲 🚫 💚 🈸 🚧 ☠️ ↩️ 📤 ❌ 1️⃣ 🥉, 👆 🎲 💚 ⚫️ **😣 🏃** 🌘 *➡ 🛠️* 👈 🚫 💔.
### ⏏ ⏮️ 💥
✋️ 👈 💼 ⏮️ 🤙 👎 ❌ 👈 💥 🏃‍♂ **🛠️**, 👆 🔜 💚 🔢 🦲 👈 🈚 **🔁** 🛠️, 🌘 👩‍❤‍👨 🕰...
!!! tip
...👐 🚥 🎂 🈸 **💥 ⏪** ⚫️ 🎲 🚫 ⚒ 🔑 🚧 🔁 ⚫️ ♾. ✋️ 📚 💼, 👆 🔜 🎲 👀 ⚫️ ⏮️ 🛠️, ⚖️ 🌘 ▶️️ ⏮️ 🛠️.
➡️ 🎯 🔛 👑 💼, 🌐❔ ⚫️ 💪 💥 🍕 🎯 💼 **🔮**, &amp; ⚫️ ⚒ 🔑 ⏏ ⚫️.
👆 🔜 🎲 💚 ✔️ 👜 🈚 🔁 👆 🈸 **🔢 🦲**, ↩️ 👈 ☝, 🎏 🈸 ⏮️ Uvicorn &amp; 🐍 ⏪ 💥, 📤 🕳 🎏 📟 🎏 📱 👈 💪 🕳 🔃 ⚫️.
### 🖼 🧰 ⏏ 🔁
🏆 💼, 🎏 🧰 👈 ⚙️ **🏃 📋 🔛 🕴** ⚙️ 🍵 🏧 **⏏**.
🖼, 👉 💪 🍵:
* ☁
* Kubernete
* ☁ ✍
* ☁ 🐝 📳
* ✳
* 👨‍💻
* 🍵 🔘 ☁ 🐕‍🦺 🍕 👫 🐕‍🦺
* 🎏...
## 🧬 - 🛠️ &amp; 💾
⏮️ FastAPI 🈸, ⚙️ 💽 📋 💖 Uvicorn, 🏃‍♂ ⚫️ 🕐 **1️⃣ 🛠️** 💪 🍦 💗 👩‍💻 🔁.
✋️ 📚 💼, 👆 🔜 💚 🏃 📚 👨‍🏭 🛠️ 🎏 🕰.
### 💗 🛠️ - 👨‍🏭
🚥 👆 ✔️ 🌅 👩‍💻 🌘 ⚫️❔ 👁 🛠️ 💪 🍵 (🖼 🚥 🕹 🎰 🚫 💁‍♂️ 🦏) &amp; 👆 ✔️ **💗 🐚** 💽 💽, ⤴️ 👆 💪 ✔️ **💗 🛠️** 🏃‍♂ ⏮️ 🎏 🈸 🎏 🕰, &amp; 📎 🌐 📨 👪 👫.
🕐❔ 👆 🏃 **💗 🛠️** 🎏 🛠️ 📋, 👫 🛎 🤙 **👨‍🏭**.
### 👨‍🏭 🛠️ &amp;
💭 ⚪️➡️ 🩺 [🔃 🇺🇸🔍](./https.md){.internal-link target=_blank} 👈 🕴 1️⃣ 🛠️ 💪 👂 🔛 1️⃣ 🌀 ⛴ &amp; 📢 📢 💽 ❓
👉 ☑.
, 💪 ✔️ **💗 🛠️** 🎏 🕰, 📤 ✔️ **👁 🛠️ 👂 🔛 ⛴** 👈 ⤴️ 📶 📻 🔠 👨‍🏭 🛠️ 🌌.
### 💾 📍 🛠️
🔜, 🕐❔ 📋 📐 👜 💾, 🖼, 🎰 🏫 🏷 🔢, ⚖️ 🎚 ⭕ 📁 🔢, 🌐 👈 **🍴 👄 💾 (💾)** 💽.
&amp; 💗 🛠️ 🛎 **🚫 💰 🙆 💾**. 👉 ⛓ 👈 🔠 🏃 🛠️ ✔️ 🚮 👍 👜, 🔢, &amp; 💾. &amp; 🚥 👆 😩 ⭕ 💸 💾 👆 📟, **🔠 🛠️** 🔜 🍴 🌓 💸 💾.
### 💽 💾
🖼, 🚥 👆 📟 📐 🎰 🏫 🏷 ⏮️ **1️⃣ 💾 📐**, 🕐❔ 👆 🏃 1️⃣ 🛠️ ⏮️ 👆 🛠️, ⚫️ 🔜 🍴 🌘 1️⃣ 💾 💾. &amp; 🚥 👆 ▶️ **4️⃣ 🛠️** (4️⃣ 👨‍🏭), 🔠 🔜 🍴 1️⃣ 💾 💾. 🌐, 👆 🛠️ 🔜 🍴 **4️⃣ 💾 💾**.
&amp; 🚥 👆 🛰 💽 ⚖️ 🕹 🎰 🕴 ✔️ 3️⃣ 💾 💾, 🔄 📐 🌅 🌘 4️⃣ 💾 💾 🔜 🤕 ⚠. 👶
### 💗 🛠️ - 🖼
👉 🖼, 📤 **👨‍💼 🛠️** 👈 ▶️ &amp; 🎛 2️⃣ **👨‍🏭 🛠️**.
👉 👨‍💼 🛠️ 🔜 🎲 1️⃣ 👂 🔛 **⛴** 📢. &amp; ⚫️ 🔜 📶 🌐 📻 👨‍🏭 🛠️.
👈 👨‍🏭 🛠️ 🔜 🕐 🏃‍♂ 👆 🈸, 👫 🔜 🎭 👑 📊 📨 **📨** &amp; 📨 **📨**, &amp; 👫 🔜 📐 🕳 👆 🚮 🔢 💾.
<img src="/img/deployment/concepts/process-ram.svg">
&amp; ↗️, 🎏 🎰 🔜 🎲 ✔️ **🎏 🛠️** 🏃 👍, ↖️ ⚪️➡️ 👆 🈸.
😌 ℹ 👈 🌐 **💽 ⚙️** 🔠 🛠️ 💪 **🪀** 📚 🤭 🕰, ✋️ **💾 (💾)** 🛎 🚧 🌖 ⚖️ 🌘 **⚖**.
🚥 👆 ✔️ 🛠️ 👈 🔨 ⭐ 💸 📊 🔠 🕰 &amp; 👆 ✔️ 📚 👩‍💻, ⤴️ **💽 🛠️** 🔜 🎲 *⚖* (↩️ 🕧 🔜 🆙 &amp; 🔽 🔜).
### 🖼 🧬 🧰 &amp; 🎛
📤 💪 📚 🎯 🏆 👉, &amp; 👤 🔜 💬 👆 🌅 🔃 🎯 🎛 ⏭ 📃, 🖼 🕐❔ 💬 🔃 ☁ &amp; 📦.
👑 ⚛ 🤔 👈 📤 ✔️ **👁** 🦲 🚚 **⛴** **📢 📢**. &amp; ⤴️ ⚫️ ✔️ ✔️ 🌌 **📶** 📻 🔁 **🛠️/👨‍🏭**.
📥 💪 🌀 &amp; 🎛:
* **🐁** 🛠️ **Uvicorn 👨‍🏭**
* 🐁 🔜 **🛠️ 👨‍💼** 👂 🔛 **📢** &amp; **⛴**, 🧬 🔜 ✔️ **💗 Uvicorn 👨‍🏭 🛠️**
* **Uvicorn** 🛠️ **Uvicorn 👨‍🏭**
* 1️⃣ Uvicorn **🛠️ 👨‍💼** 🔜 👂 🔛 **📢** &amp; **⛴**, &amp; ⚫️ 🔜 ▶️ **💗 Uvicorn 👨‍🏭 🛠️**
* **Kubernete** &amp; 🎏 📎 **📦 ⚙️**
* 🕳 **☁** 🧽 🔜 👂 🔛 **📢** &amp; **⛴**. 🧬 🔜 ✔️ **💗 📦**, 🔠 ⏮️ **1️⃣ Uvicorn 🛠️** 🏃‍♂
* **☁ 🐕‍🦺** 👈 🍵 👉 👆
* ☁ 🐕‍🦺 🔜 🎲 **🍵 🧬 👆**. ⚫️ 🔜 🎲 ➡️ 👆 🔬 **🛠️ 🏃**, ⚖️ **📦 🖼** ⚙️, 🙆 💼, ⚫️ 🔜 🌅 🎲 **👁 Uvicorn 🛠️**, &amp; ☁ 🐕‍🦺 🔜 🈚 🔁 ⚫️.
!!! tip
🚫 😟 🚥 👫 🏬 🔃 **📦**, ☁, ⚖️ Kubernete 🚫 ⚒ 📚 🔑.
👤 🔜 💬 👆 🌅 🔃 📦 🖼, ☁, Kubernete, ♒️. 🔮 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
## ⏮️ 🔁 ⏭ ▶️
📤 📚 💼 🌐❔ 👆 💚 🎭 📶 **⏭ ▶️** 👆 🈸.
🖼, 👆 💪 💚 🏃 **💽 🛠️**.
✋️ 🌅 💼, 👆 🔜 💚 🎭 👉 🔁 🕴 **🕐**.
, 👆 🔜 💚 ✔️ **👁 🛠️** 🎭 👈 **⏮️ 🔁**, ⏭ ▶️ 🈸.
&amp; 👆 🔜 ✔️ ⚒ 💭 👈 ⚫️ 👁 🛠️ 🏃 👈 ⏮️ 🔁 ** 🚥 ⏮️, 👆 ▶️ **💗 🛠️** (💗 👨‍🏭) 🈸 ⚫️. 🚥 👈 🔁 🏃 **💗 🛠️**, 👫 🔜 **❎** 👷 🏃‍♂ ⚫️ 🔛 **🔗**, &amp; 🚥 📶 🕳 💎 💖 💽 🛠️, 👫 💪 🤕 ⚔ ⏮️ 🔠 🎏.
↗️, 📤 💼 🌐❔ 📤 🙅‍♂ ⚠ 🏃 ⏮️ 🔁 💗 🕰, 👈 💼, ⚫️ 📚 ⏩ 🍵.
!!! tip
, ✔️ 🤯 👈 ⚓️ 🔛 👆 🖥, 💼 👆 **5️⃣📆 🚫 💪 🙆 ⏮️ 🔁** ⏭ ▶️ 👆 🈸.
👈 💼, 👆 🚫🔜 ✔️ 😟 🔃 🙆 👉. 🤷
### 🖼 ⏮️ 🔁 🎛
👉 🔜 **🪀 🙇** 🔛 🌌 👆 **🛠️ 👆 ⚙️**, &amp; ⚫️ 🔜 🎲 🔗 🌌 👆 ▶️ 📋, 🚚 ⏏, ♒️.
📥 💪 💭:
* "🕑 📦" Kubernete 👈 🏃 ⏭ 👆 📱 📦
* 🎉 ✍ 👈 🏃 ⏮️ 🔁 &amp; ⤴️ ▶️ 👆 🈸
* 👆 🔜 💪 🌌 ▶️/⏏ *👈* 🎉 ✍, 🔍 ❌, ♒️.
!!! tip
👤 🔜 🤝 👆 🌅 🧱 🖼 🔨 👉 ⏮️ 📦 🔮 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
## ℹ 🛠️
👆 💽(Ⓜ) () **ℹ**, 👆 💪 🍴 ⚖️ **⚙️**, ⏮️ 👆 📋, 📊 🕰 🔛 💽, &amp; 💾 💾 💪.
❔ 🌅 ⚙️ ℹ 👆 💚 😩/♻ ❓ ⚫️ 💪 ⏩ 💭 "🚫 🌅", ✋️ 🌌, 👆 🔜 🎲 💚 🍴 **🌅 💪 🍵 💥**.
🚥 👆 💸 3️⃣ 💽 ✋️ 👆 ⚙️ 🕴 🐥 🍖 👫 💾 &amp; 💽, 👆 🎲 **🗑 💸** 👶, &amp; 🎲 **🗑 💽 🔦 🏋️** 👶, ♒️.
👈 💼, ⚫️ 💪 👻 ✔️ 🕴 2️⃣ 💽 &amp; ⚙️ ↕ 🌐 👫 ℹ (💽, 💾, 💾, 🕸 💿, ♒️).
🔛 🎏 ✋, 🚥 👆 ✔️ 2️⃣ 💽 &amp; 👆 ⚙️ **1️⃣0️⃣0️⃣ 💯 👫 💽 &amp; 💾**, ☝ 1️⃣ 🛠️ 🔜 💭 🌅 💾, &amp; 💽 🔜 ✔️ ⚙️ 💾 "💾" (❔ 💪 💯 🕰 🐌), ⚖️ **💥**. ⚖️ 1️⃣ 🛠️ 💪 💪 📊 &amp; 🔜 ✔️ ⌛ ⏭ 💽 🆓 🔄.
👉 💼, ⚫️ 🔜 👍 🤚 **1️⃣ ➕ 💽** &amp; 🏃 🛠️ 🔛 ⚫️ 👈 👫 🌐 ✔️ **🥃 💾 &amp; 💽 🕰**.
📤 🤞 👈 🤔 👆 ✔️ **🌵** ⚙️ 👆 🛠️. 🎲 ⚫️ 🚶 🦠, ⚖️ 🎲 🎏 🐕‍🦺 ⚖️ 🤖 ▶️ ⚙️ ⚫️. &amp; 👆 💪 💚 ✔️ ➕ ℹ 🔒 👈 💼.
👆 💪 🚮 **❌ 🔢** 🎯, 🖼, 🕳 **🖖 5️⃣0️⃣ 💯 9️⃣0️⃣ 💯** ℹ 🛠️. ☝ 👈 📚 🎲 👑 👜 👆 🔜 💚 ⚖ &amp; ⚙️ ⚒ 👆 🛠️.
👆 💪 ⚙️ 🙅 🧰 💖 `htop` 👀 💽 &amp; 💾 ⚙️ 👆 💽 ⚖️ 💸 ⚙️ 🔠 🛠️. ⚖️ 👆 💪 ⚙️ 🌖 🏗 ⚖ 🧰, ❔ 5️⃣📆 📎 🤭 💽, ♒️.
## 🌃
👆 ✔️ 👂 📥 👑 🔧 👈 👆 🔜 🎲 💪 ✔️ 🤯 🕐❔ 🤔 ❔ 🛠️ 👆 🈸:
* 💂‍♂ - 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* 🧬 (🔢 🛠️ 🏃)
* 💾
* ⏮️ 🔁 ⏭ ▶️
🤔 👉 💭 &amp; ❔ ✔ 👫 🔜 🤝 👆 🤔 💪 ✊ 🙆 🚫 🕐❔ 🛠️ &amp; 🛠️ 👆 🛠️. 👶
⏭ 📄, 👤 🔜 🤝 👆 🌅 🧱 🖼 💪 🎛 👆 💪 ⏩. 👶

258
docs/em/docs/deployment/deta.md

@ -0,0 +1,258 @@
# 🛠️ FastAPI 🔛 🪔
👉 📄 👆 🔜 💡 ❔ 💪 🛠️ **FastAPI** 🈸 🔛 <a href="https://www.deta.sh/?ref=fastapi" class="external-link" target="_blank">🪔</a> ⚙️ 🆓 📄. 👶
⚫️ 🔜 ✊ 👆 🔃 **1️⃣0️⃣ ⏲**.
!!! info
<a href="https://www.deta.sh/?ref=fastapi" class="external-link" target="_blank">🪔</a> **FastAPI** 💰. 👶
## 🔰 **FastAPI** 📱
* ✍ 📁 👆 📱, 🖼, `./fastapideta/` &amp; ⛔ 🔘 ⚫️.
### FastAPI 📟
* ✍ `main.py` 📁 ⏮️:
```Python
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
```
### 📄
🔜, 🎏 📁 ✍ 📁 `requirements.txt` ⏮️:
```text
fastapi
```
!!! tip
👆 🚫 💪 ❎ Uvicorn 🛠️ 🔛 🪔, 👐 👆 🔜 🎲 💚 ❎ ⚫️ 🌐 💯 👆 📱.
### 📁 📊
👆 🔜 🔜 ✔️ 1️⃣ 📁 `./fastapideta/` ⏮️ 2️⃣ 📁:
```
.
└── main.py
└── requirements.txt
```
## ✍ 🆓 🪔 🏧
🔜 ✍ <a href="https://www.deta.sh/?ref=fastapi" class="external-link" target="_blank">🆓 🏧 🔛 🪔</a>, 👆 💪 📧 &amp; 🔐.
👆 🚫 💪 💳.
## ❎ ✳
🕐 👆 ✔️ 👆 🏧, ❎ 🪔 <abbr title="Command Line Interface application"></abbr>:
=== "💾, 🇸🇻"
<div class="termy">
```console
$ curl -fsSL https://get.deta.dev/cli.sh | sh
```
</div>
=== "🚪 📋"
<div class="termy">
```console
$ iwr https://get.deta.dev/cli.ps1 -useb | iex
```
</div>
⏮️ ❎ ⚫️, 📂 🆕 📶 👈 ❎ ✳ 🔍.
🆕 📶, ✔ 👈 ⚫️ ☑ ❎ ⏮️:
<div class="termy">
```console
$ deta --help
Deta command line interface for managing deta micros.
Complete documentation available at https://docs.deta.sh
Usage:
deta [flags]
deta [command]
Available Commands:
auth Change auth settings for a deta micro
...
```
</div>
!!! tip
🚥 👆 ✔️ ⚠ ❎ ✳, ✅ <a href="https://docs.deta.sh/docs/micros/getting_started?ref=fastapi" class="external-link" target="_blank">🛂 🪔 🩺</a>.
## 💳 ⏮️ ✳
🔜 💳 🪔 ⚪️➡️ ✳ ⏮️:
<div class="termy">
```console
$ deta login
Please, log in from the web page. Waiting..
Logged in successfully.
```
</div>
👉 🔜 📂 🕸 🖥 &amp; 🔓 🔁.
## 🛠️ ⏮️ 🪔
⏭, 🛠️ 👆 🈸 ⏮️ 🪔 ✳:
<div class="termy">
```console
$ deta new
Successfully created a new micro
// Notice the "endpoint" 🔍
{
"name": "fastapideta",
"runtime": "python3.7",
"endpoint": "https://qltnci.deta.dev",
"visor": "enabled",
"http_auth": "enabled"
}
Adding dependencies...
---> 100%
Successfully installed fastapi-0.61.1 pydantic-1.7.2 starlette-0.13.6
```
</div>
👆 🔜 👀 🎻 📧 🎏:
```JSON hl_lines="4"
{
"name": "fastapideta",
"runtime": "python3.7",
"endpoint": "https://qltnci.deta.dev",
"visor": "enabled",
"http_auth": "enabled"
}
```
!!! tip
👆 🛠️ 🔜 ✔️ 🎏 `"endpoint"` 📛.
## ✅ ⚫️
🔜 📂 👆 🖥 👆 `endpoint` 📛. 🖼 🔛 ⚫️ `https://qltnci.deta.dev`, ✋️ 👆 🔜 🎏.
👆 🔜 👀 🎻 📨 ⚪️➡️ 👆 FastAPI 📱:
```JSON
{
"Hello": "World"
}
```
&amp; 🔜 🚶 `/docs` 👆 🛠️, 🖼 🔛 ⚫️ 🔜 `https://qltnci.deta.dev/docs`.
⚫️ 🔜 🎦 👆 🩺 💖:
<img src="/img/deployment/deta/image01.png">
## 🛠️ 📢 🔐
🔢, 🪔 🔜 🍵 🤝 ⚙️ 🍪 👆 🏧.
✋️ 🕐 👆 🔜, 👆 💪 ⚒ ⚫️ 📢 ⏮️:
<div class="termy">
```console
$ deta auth disable
Successfully disabled http auth
```
</div>
🔜 👆 💪 💰 👈 📛 ⏮️ 🙆 &amp; 👫 🔜 💪 🔐 👆 🛠️. 👶
## 🇺🇸🔍
㊗ ❗ 👆 🛠️ 👆 FastAPI 📱 🪔 ❗ 👶 👶
, 👀 👈 🪔 ☑ 🍵 🇺🇸🔍 👆, 👆 🚫 ✔️ ✊ 💅 👈 &amp; 💪 💭 👈 👆 👩‍💻 🔜 ✔️ 🔐 🗜 🔗. 👶 👶
## ✅ 🕶
⚪️➡️ 👆 🩺 🎚 (👫 🔜 📛 💖 `https://qltnci.deta.dev/docs`) 📨 📨 👆 *➡ 🛠️* `/items/{item_id}`.
🖼 ⏮️ 🆔 `5`.
🔜 🚶 <a href="https://web.deta.sh/" class="external-link" target="_blank">https://web.deta.sh</a>.
👆 🔜 👀 📤 📄 ◀️ 🤙 <abbr title="it comes from Micro(server)">"◾"</abbr> ⏮️ 🔠 👆 📱.
👆 🔜 👀 📑 ⏮️ "ℹ", &amp; 📑 "🕶", 🚶 📑 "🕶".
📤 👆 💪 ✔ ⏮️ 📨 📨 👆 📱.
👆 💪 ✍ 👫 &amp; 🏤-🤾 👫.
<img src="/img/deployment/deta/image02.png">
## 💡 🌅
☝, 👆 🔜 🎲 💚 🏪 💽 👆 📱 🌌 👈 😣 🔘 🕰. 👈 👆 💪 ⚙️ <a href="https://docs.deta.sh/docs/base/py_tutorial?ref=fastapi" class="external-link" target="_blank">🪔 🧢</a>, ⚫️ ✔️ 👍 **🆓 🎚**.
👆 💪 ✍ 🌅 <a href="https://docs.deta.sh?ref=fastapi" class="external-link" target="_blank">🪔 🩺</a>.
## 🛠️ 🔧
👟 🔙 🔧 👥 🔬 [🛠️ 🔧](./concepts.md){.internal-link target=_blank}, 📥 ❔ 🔠 👫 🔜 🍵 ⏮️ 🪔:
* **🇺🇸🔍**: 🍵 🪔, 👫 🔜 🤝 👆 📁 &amp; 🍵 🇺🇸🔍 🔁.
* **🏃‍♂ 🔛 🕴**: 🍵 🪔, 🍕 👫 🐕‍🦺.
* **⏏**: 🍵 🪔, 🍕 👫 🐕‍🦺.
* **🧬**: 🍵 🪔, 🍕 👫 🐕‍🦺.
* **💾**: 📉 🔁 🪔, 👆 💪 📧 👫 📈 ⚫️.
* **⏮️ 🔁 ⏭ ▶️**: 🚫 🔗 🐕‍🦺, 👆 💪 ⚒ ⚫️ 👷 ⏮️ 👫 💾 ⚙️ ⚖️ 🌖 ✍.
!!! note
🪔 🔧 ⚒ ⚫️ ⏩ (&amp; 🆓) 🛠️ 🙅 🈸 🔜.
⚫️ 💪 📉 📚 ⚙️ 💼, ✋️ 🎏 🕰, ⚫️ 🚫 🐕‍🦺 🎏, 💖 ⚙️ 🔢 💽 (↖️ ⚪️➡️ 🪔 👍 ☁ 💽 ⚙️), 🛃 🕹 🎰, ♒️.
👆 💪 ✍ 🌅 ℹ <a href="https://docs.deta.sh/docs/micros/about/" class="external-link" target="_blank">🪔 🩺</a> 👀 🚥 ⚫️ ▶️️ ⚒ 👆.

698
docs/em/docs/deployment/docker.md

@ -0,0 +1,698 @@
# FastAPI 📦 - ☁
🕐❔ 🛠️ FastAPI 🈸 ⚠ 🎯 🏗 **💾 📦 🖼**. ⚫️ 🛎 🔨 ⚙️ <a href="https://www.docker.com/" class="external-link" target="_blank">**☁**</a>. 👆 💪 ⤴️ 🛠️ 👈 📦 🖼 1️⃣ 👩‍❤‍👨 💪 🌌.
⚙️ 💾 📦 ✔️ 📚 📈 ✅ **💂‍♂**, **🔬**, **🦁**, &amp; 🎏.
!!! tip
🏃 &amp; ⏪ 💭 👉 💩 ❓ 🦘 [`Dockerfile` 🔛 👶](#build-a-docker-image-for-fastapi).
<details>
<summary>📁 🎮 👶</summary>
```Dockerfile
FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
# If running behind a proxy like Nginx or Traefik add --proxy-headers
# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80", "--proxy-headers"]
```
</details>
## ⚫️❔ 📦
📦 (✴️ 💾 📦) 📶 **💿** 🌌 📦 🈸 ✅ 🌐 👫 🔗 &amp; 💪 📁 ⏪ 🚧 👫 ❎ ⚪️➡️ 🎏 📦 (🎏 🈸 ⚖️ 🦲) 🎏 ⚙️.
💾 📦 🏃 ⚙️ 🎏 💾 💾 🦠 (🎰, 🕹 🎰, ☁ 💽, ♒️). 👉 ⛓ 👈 👫 📶 💿 (🔬 🌕 🕹 🎰 👍 🎂 🏃‍♂ ⚙️).
👉 🌌, 📦 🍴 **🐥 ℹ**, 💸 ⭐ 🏃‍♂ 🛠️ 🔗 (🕹 🎰 🔜 🍴 🌅 🌅).
📦 ✔️ 👫 👍 **❎** 🏃‍♂ 🛠️ (🛎 1️⃣ 🛠️), 📁 ⚙️, &amp; 🕸, 🔬 🛠️, 💂‍♂, 🛠️, ♒️.
## ⚫️❔ 📦 🖼
**📦** 🏃 ⚪️➡️ **📦 🖼**.
📦 🖼 **🎻** ⏬ 🌐 📁, 🌐 🔢, &amp; 🔢 📋/📋 👈 🔜 🎁 📦. **🎻** 📥 ⛓ 👈 📦 **🖼** 🚫 🏃, ⚫️ 🚫 ➖ 🛠️, ⚫️ 🕴 📦 📁 &amp; 🗃.
🔅 "**📦 🖼**" 👈 🏪 🎻 🎚,"**📦**" 🛎 🔗 🏃‍♂ 👐, 👜 👈 ➖ **🛠️**.
🕐❔ **📦** ▶️ &amp; 🏃‍♂ (▶️ ⚪️➡️ **📦 🖼**) ⚫️ 💪 ✍ ⚖️ 🔀 📁, 🌐 🔢, ♒️. 👈 🔀 🔜 🔀 🕴 👈 📦, ✋️ 🔜 🚫 😣 👽 📦 🖼 (🔜 🚫 🖊 💾).
📦 🖼 ⭐ **📋** 📁 &amp; 🎚, ✅ `python` &amp; 📁 `main.py`.
&amp; **📦** ⚫️ (🔅 **📦 🖼**) ☑ 🏃 👐 🖼, ⭐ **🛠️**. 👐, 📦 🏃 🕴 🕐❔ ⚫️ ✔️ **🛠️ 🏃** (&amp; 🛎 ⚫️ 🕴 👁 🛠️). 📦 ⛔️ 🕐❔ 📤 🙅‍♂ 🛠️ 🏃 ⚫️.
## 📦 🖼
☁ ✔️ 1️⃣ 👑 🧰 ✍ &amp; 🛠️ **📦 🖼** &amp; **📦**.
&amp; 📤 📢 <a href="https://hub.docker.com/" class="external-link" target="_blank">☁ 🎡</a> ⏮️ 🏤-⚒ **🛂 📦 🖼** 📚 🧰, 🌐, 💽, &amp; 🈸.
🖼, 📤 🛂 <a href="https://hub.docker.com/_/python" class="external-link" target="_blank">🐍 🖼</a>.
&amp; 📤 📚 🎏 🖼 🎏 👜 💖 💽, 🖼:
* <a href="https://hub.docker.com/_/postgres" class="external-link" target="_blank"></a>
* <a href="https://hub.docker.com/_/mysql" class="external-link" target="_blank"></a>
* <a href="https://hub.docker.com/_/mongo" class="external-link" target="_blank"></a>
* <a href="https://hub.docker.com/_/redis" class="external-link" target="_blank"></a>, ♒️.
⚙️ 🏤-⚒ 📦 🖼 ⚫️ 📶 ⏩ **🌀** &amp; ⚙️ 🎏 🧰. 🖼, 🔄 👅 🆕 💽. 🌅 💼, 👆 💪 ⚙️ **🛂 🖼**, &amp; 🔗 👫 ⏮️ 🌐 🔢.
👈 🌌, 📚 💼 👆 💪 💡 🔃 📦 &amp;&amp; 🏤-⚙️ 👈 💡 ⏮️ 📚 🎏 🧰 &amp; 🦲.
, 👆 🔜 🏃 **💗 📦** ⏮️ 🎏 👜, 💖 💽, 🐍 🈸, 🕸 💽 ⏮️ 😥 🕸 🈸, &amp; 🔗 👫 👯‍♂️ 📨 👫 🔗 🕸.
🌐 📦 🧾 ⚙️ (💖 ☁ ⚖️ Kubernete) ✔️ 👫 🕸 ⚒ 🛠️ 🔘 👫.
## 📦 &amp; 🛠️
**📦 🖼** 🛎 🔌 🚮 🗃 🔢 📋 ⚖️ 📋 👈 🔜 🏃 🕐❔ **📦** ▶️ &amp; 🔢 🚶‍♀️ 👈 📋. 📶 🎏 ⚫️❔ 🔜 🚥 ⚫️ 📋 ⏸.
🕐❔ **📦** ▶️, ⚫️ 🔜 🏃 👈 📋/📋 (👐 👆 💪 🔐 ⚫️ &amp; ⚒ ⚫️ 🏃 🎏 📋/📋).
📦 🏃 📏 **👑 🛠️** (📋 ⚖️ 📋) 🏃.
📦 🛎 ✔️ **👁 🛠️**, ✋️ ⚫️ 💪 ▶️ ✳ ⚪️➡️ 👑 🛠️, &amp; 👈 🌌 👆 🔜 ✔️ **💗 🛠️** 🎏 📦.
✋️ ⚫️ 🚫 💪 ✔️ 🏃‍♂ 📦 🍵 **🌘 1️⃣ 🏃‍♂ 🛠️**. 🚥 👑 🛠️ ⛔️, 📦 ⛔️.
## 🏗 ☁ 🖼 FastAPI
🆗, ➡️ 🏗 🕳 🔜 ❗ 👶
👤 🔜 🎦 👆 ❔ 🏗 **☁ 🖼** FastAPI **⚪️➡️ 🖌**, ⚓️ 🔛 **🛂 🐍** 🖼.
👉 ⚫️❔ 👆 🔜 💚 **🏆 💼**, 🖼:
* ⚙️ **Kubernete** ⚖️ 🎏 🧰
* 🕐❔ 🏃‍♂ 🔛 **🍓 👲**
* ⚙️ ☁ 🐕‍🦺 👈 🔜 🏃 📦 🖼 👆, ♒️.
### 📦 📄
👆 🔜 🛎 ✔️ **📦 📄** 👆 🈸 📁.
⚫️ 🔜 🪀 ✴️ 🔛 🧰 👆 ⚙️ **❎** 👈 📄.
🌅 ⚠ 🌌 ⚫️ ✔️ 📁 `requirements.txt` ⏮️ 📦 📛 &amp; 👫 ⏬, 1️⃣ 📍 ⏸.
👆 🔜 ↗️ ⚙️ 🎏 💭 👆 ✍ [🔃 FastAPI ⏬](./versions.md){.internal-link target=_blank} ⚒ ↔ ⏬.
🖼, 👆 `requirements.txt` 💪 👀 💖:
```
fastapi>=0.68.0,<0.69.0
pydantic>=1.8.0,<2.0.0
uvicorn>=0.15.0,<0.16.0
```
&amp; 👆 🔜 🛎 ❎ 👈 📦 🔗 ⏮️ `pip`, 🖼:
<div class="termy">
```console
$ pip install -r requirements.txt
---> 100%
Successfully installed fastapi pydantic uvicorn
```
</div>
!!! info
📤 🎏 📁 &amp; 🧰 🔬 &amp; ❎ 📦 🔗.
👤 🔜 🎦 👆 🖼 ⚙️ 🎶 ⏪ 📄 🔛. 👶
### ✍ **FastAPI** 📟
* ✍ `app` 📁 &amp; ⛔ ⚫️.
* ✍ 🛁 📁 `__init__.py`.
* ✍ `main.py` 📁 ⏮️:
```Python
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
```
### 📁
🔜 🎏 🏗 📁 ✍ 📁 `Dockerfile` ⏮️:
```{ .dockerfile .annotate }
# (1)
FROM python:3.9
# (2)
WORKDIR /code
# (3)
COPY ./requirements.txt /code/requirements.txt
# (4)
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# (5)
COPY ./app /code/app
# (6)
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
```
1️⃣. ▶️ ⚪️➡️ 🛂 🐍 🧢 🖼.
2️⃣. ⚒ ⏮️ 👷 📁 `/code`.
👉 🌐❔ 👥 🔜 🚮 `requirements.txt` 📁 &amp; `app` 📁.
3️⃣. 📁 📁 ⏮️ 📄 `/code` 📁.
📁 **🕴** 📁 ⏮️ 📄 🥇, 🚫 🎂 📟.
👉 📁 **🚫 🔀 🛎**, ☁ 🔜 🔍 ⚫️ &amp; ⚙️ **💾** 👉 🔁, 🛠️ 💾 ⏭ 🔁 💁‍♂️.
4️⃣. ❎ 📦 🔗 📄 📁.
`--no-cache-dir` 🎛 💬 `pip` 🚫 🖊 ⏬ 📦 🌐, 👈 🕴 🚥 `pip` 🔜 🏃 🔄 ❎ 🎏 📦, ✋️ 👈 🚫 💼 🕐❔ 👷 ⏮️ 📦.
!!! note
`--no-cache-dir` 🕴 🔗 `pip`, ⚫️ ✔️ 🕳 ⏮️ ☁ ⚖️ 📦.
`--upgrade` 🎛 💬 `pip` ♻ 📦 🚥 👫 ⏪ ❎.
↩️ ⏮️ 🔁 🖨 📁 💪 🔍 **☁ 💾**, 👉 🔁 🔜 **⚙️ ☁ 💾** 🕐❔ 💪.
⚙️ 💾 👉 🔁 🔜 **🖊** 👆 📚 **🕰** 🕐❔ 🏗 🖼 🔄 &amp; 🔄 ⏮️ 🛠️, ↩️ **&amp; ❎** 🌐 🔗 **🔠 🕰**.
5️⃣. 📁 `./app` 📁 🔘 `/code` 📁.
👉 ✔️ 🌐 📟 ❔ ⚫️❔ **🔀 🌅 🛎** ☁ **💾** 🏆 🚫 ⚙️ 👉 ⚖️ 🙆 **📄 🔁** 💪.
, ⚫️ ⚠ 🚮 👉 **🏘 🔚** `Dockerfile`, 🔬 📦 🖼 🏗 🕰.
6️⃣. ⚒ **📋** 🏃 `uvicorn` 💽.
`CMD` ✊ 📇 🎻, 🔠 👫 🎻 ⚫️❔ 👆 🔜 🆎 📋 ⏸ 👽 🚀.
👉 📋 🔜 🏃 ⚪️➡️ **⏮️ 👷 📁**, 🎏 `/code` 📁 👆 ⚒ 🔛 ⏮️ `WORKDIR /code`.
↩️ 📋 🔜 ▶️ `/code` &amp; 🔘 ⚫️ 📁 `./app` ⏮️ 👆 📟, **Uvicorn** 🔜 💪 👀 &amp; **🗄** `app` ⚪️➡️ `app.main`.
!!! tip
📄 ⚫️❔ 🔠 ⏸ 🔨 🖊 🔠 🔢 💭 📟. 👶
👆 🔜 🔜 ✔️ 📁 📊 💖:
```
.
├── app
│   ├── __init__.py
│ └── main.py
├── Dockerfile
└── requirements.txt
```
#### ⛅ 🤝 ❎ 🗳
🚥 👆 🏃‍♂ 👆 📦 ⛅ 🤝 ❎ 🗳 (📐 ⚙) 💖 👌 ⚖️ Traefik, 🚮 🎛 `--proxy-headers`, 👉 🔜 💬 Uvicorn 💙 🎚 📨 👈 🗳 💬 ⚫️ 👈 🈸 🏃 ⛅ 🇺🇸🔍, ♒️.
```Dockerfile
CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
```
#### ☁ 💾
📤 ⚠ 🎱 👉 `Dockerfile`, 👥 🥇 📁 **📁 ⏮️ 🔗 😞**, 🚫 🎂 📟. ➡️ 👤 💬 👆 ⚫️❔ 👈.
```Dockerfile
COPY ./requirements.txt /code/requirements.txt
```
&amp; 🎏 🧰 **🏗** 👉 📦 🖼 **🔁**, 🚮 **1️⃣ 🧽 🔛 🔝 🎏**, ▶️ ⚪️➡️ 🔝 `Dockerfile` &amp; ❎ 🙆 📁 ✍ 🔠 👩‍🌾 `Dockerfile`.
&amp; 🎏 🧰 ⚙️ **🔗 💾** 🕐❔ 🏗 🖼, 🚥 📁 🚫 🔀 ↩️ 🏁 🕰 🏗 📦 🖼, ⤴️ ⚫️ 🔜 **🏤-⚙️ 🎏 🧽** ✍ 🏁 🕰, ↩️ 🖨 📁 🔄 &amp; 🏗 🆕 🧽 ⚪️➡️ 🖌.
❎ 📁 📁 🚫 🎯 📉 👜 💁‍♂️ 🌅, ✋️ ↩️ ⚫️ ⚙️ 💾 👈 🔁, ⚫️ 💪 **⚙️ 💾 ⏭ 🔁**. 🖼, ⚫️ 💪 ⚙️ 💾 👩‍🌾 👈 ❎ 🔗 ⏮️:
```Dockerfile
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
```
📁 ⏮️ 📦 📄 **🏆 🚫 🔀 🛎**. , 🖨 🕴 👈 📁, ☁ 🔜 💪 **⚙️ 💾** 👈 🔁.
&amp; ⤴️, ☁ 🔜 💪 **⚙️ 💾 ⏭ 🔁** 👈 ⏬ &amp; ❎ 👈 🔗. &amp; 📥 🌐❔ 👥 **🖊 📚 🕰**. 👶 ...&amp; ❎ 😩 ⌛. 👶 👶
&amp; ❎ 📦 🔗 **💪 ✊ ⏲**, ✋️ ⚙️ **💾** 🔜 **✊ 🥈** 🌅.
&amp; 👆 🔜 🏗 📦 🖼 🔄 &amp; 🔄 ⏮️ 🛠️ ✅ 👈 👆 📟 🔀 👷, 📤 📚 📈 🕰 👉 🔜 🖊.
⤴️, 🏘 🔚 `Dockerfile`, 👥 📁 🌐 📟. 👉 ⚫️❔ **🔀 🏆 🛎**, 👥 🚮 ⚫️ 🏘 🔚, ↩️ 🌖 🕧, 🕳 ⏮️ 👉 🔁 🔜 🚫 💪 ⚙️ 💾.
```Dockerfile
COPY ./app /code/app
```
### 🏗 ☁ 🖼
🔜 👈 🌐 📁 🥉, ➡️ 🏗 📦 🖼.
* 🚶 🏗 📁 (🌐❔ 👆 `Dockerfile` , ⚗ 👆 `app` 📁).
* 🏗 👆 FastAPI 🖼:
<div class="termy">
```console
$ docker build -t myimage .
---> 100%
```
</div>
!!! tip
👀 `.` 🔚, ⚫️ 🌓 `./`, ⚫️ 💬 ☁ 📁 ⚙️ 🏗 📦 🖼.
👉 💼, ⚫️ 🎏 ⏮️ 📁 (`.`).
### ▶️ ☁ 📦
* 🏃 📦 ⚓️ 🔛 👆 🖼:
<div class="termy">
```console
$ docker run -d --name mycontainer -p 80:80 myimage
```
</div>
## ✅ ⚫️
👆 🔜 💪 ✅ ⚫️ 👆 ☁ 📦 📛, 🖼: <a href="http://192.168.99.100/items/5?q=somequery" class="external-link" target="_blank">http://192.168.99.100/items/5?q=somequery</a> ⚖️ <a href="http://127.0.0.1/items/5?q=somequery" class="external-link" target="_blank">http://127.0.0.1/items/5?q=somequery</a> (⚖️ 🌓, ⚙️ 👆 ☁ 🦠).
👆 🔜 👀 🕳 💖:
```JSON
{"item_id": 5, "q": "somequery"}
```
## 🎓 🛠️ 🩺
🔜 👆 💪 🚶 <a href="http://192.168.99.100/docs" class="external-link" target="_blank">http://192.168.99.100/docs</a> ⚖️ <a href="http://127.0.0.1/docs" class="external-link" target="_blank">http://127.0.0.1/docs</a> (⚖️ 🌓, ⚙️ 👆 ☁ 🦠).
👆 🔜 👀 🏧 🎓 🛠️ 🧾 (🚚 <a href="https://github.com/swagger-api/swagger-ui" class="external-link" target="_blank">🦁 🎚</a>):
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-01-swagger-ui-simple.png)
## 🎛 🛠️ 🩺
&amp; 👆 💪 🚶 <a href="http://192.168.99.100/redoc" class="external-link" target="_blank">http://192.168.99.100/redoc</a> ⚖️ <a href="http://127.0.0.1/redoc" class="external-link" target="_blank">http://127.0.0.1/redoc</a> (⚖️ 🌓, ⚙️ 👆 ☁ 🦠).
👆 🔜 👀 🎛 🏧 🧾 (🚚 <a href="https://github.com/Rebilly/ReDoc" class="external-link" target="_blank">📄</a>):
![ReDoc](https://fastapi.tiangolo.com/img/index/index-02-redoc-simple.png)
## 🏗 ☁ 🖼 ⏮️ 👁-📁 FastAPI
🚥 👆 FastAPI 👁 📁, 🖼, `main.py` 🍵 `./app` 📁, 👆 📁 📊 💪 👀 💖 👉:
```
.
├── Dockerfile
├── main.py
└── requirements.txt
```
⤴️ 👆 🔜 ✔️ 🔀 🔗 ➡ 📁 📁 🔘 `Dockerfile`:
```{ .dockerfile .annotate hl_lines="10 13" }
FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# (1)
COPY ./main.py /code/
# (2)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
```
1️⃣. 📁 `main.py` 📁 `/code` 📁 🔗 (🍵 🙆 `./app` 📁).
2️⃣. 🏃 Uvicorn &amp; 💬 ⚫️ 🗄 `app` 🎚 ⚪️➡️ `main` (↩️ 🏭 ⚪️➡️ `app.main`).
⤴️ 🔆 Uvicorn 📋 ⚙️ 🆕 🕹 `main` ↩️ `app.main` 🗄 FastAPI 🎚 `app`.
## 🛠️ 🔧
➡️ 💬 🔄 🔃 🎏 [🛠️ 🔧](./concepts.md){.internal-link target=_blank} ⚖ 📦.
📦 ✴️ 🧰 📉 🛠️ **🏗 &amp; 🛠️** 🈸, ✋️ 👫 🚫 🛠️ 🎯 🎯 🍵 👉 **🛠️ 🔧**, &amp; 📤 📚 💪 🎛.
**👍 📰** 👈 ⏮️ 🔠 🎏 🎛 📤 🌌 📔 🌐 🛠️ 🔧. 👶
➡️ 📄 👉 **🛠️ 🔧** ⚖ 📦:
* 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* 🧬 (🔢 🛠️ 🏃)
* 💾
* ⏮️ 🔁 ⏭ ▶️
## 🇺🇸🔍
🚥 👥 🎯 🔛 **📦 🖼** FastAPI 🈸 (&amp; ⏪ 🏃‍♂ **📦**), 🇺🇸🔍 🛎 🔜 🍵 **🗜** ➕1️⃣ 🧰.
⚫️ 💪 ➕1️⃣ 📦, 🖼 ⏮️ <a href="https://traefik.io/" class="external-link" target="_blank">Traefik</a>, 🚚 **🇺🇸🔍** &amp; **🏧** 🛠️ **📄**.
!!! tip
Traefik ✔️ 🛠️ ⏮️ ☁, Kubernete, &amp; 🎏, ⚫️ 📶 ⏩ ⚒ 🆙 &amp; 🔗 🇺🇸🔍 👆 📦 ⏮️ ⚫️.
👐, 🇺🇸🔍 💪 🍵 ☁ 🐕‍🦺 1️⃣ 👫 🐕‍🦺 (⏪ 🏃 🈸 📦).
## 🏃‍♂ 🔛 🕴 &amp;
📤 🛎 ➕1️⃣ 🧰 🈚 **▶️ &amp; 🏃‍♂** 👆 📦.
⚫️ 💪 **☁** 🔗, **☁ ✍**, **Kubernete**, **☁ 🐕‍🦺**, ♒️.
🌅 (⚖️ 🌐) 💼, 📤 🙅 🎛 🛠️ 🏃 📦 🔛 🕴 &amp; 🛠️ ⏏ 🔛 ❌. 🖼, ☁, ⚫️ 📋 ⏸ 🎛 `--restart`.
🍵 ⚙️ 📦, ⚒ 🈸 🏃 🔛 🕴 &amp; ⏮️ ⏏ 💪 ⚠ &amp; ⚠. ✋️ 🕐❔ **👷 ⏮️ 📦** 🌅 💼 👈 🛠️ 🔌 🔢. 👶
## 🧬 - 🔢 🛠️
🚥 👆 ✔️ <abbr title="A group of machines that are configured to be connected and work together in some way.">🌑</abbr> 🎰 ⏮️ **☁**, ☁ 🐝 📳, 🖖, ⚖️ ➕1️⃣ 🎏 🏗 ⚙️ 🛠️ 📎 📦 🔛 💗 🎰, ⤴️ 👆 🔜 🎲 💚 **🍵 🧬** **🌑 🎚** ↩️ ⚙️ **🛠️ 👨‍💼** (💖 🐁 ⏮️ 👨‍🏭) 🔠 📦.
1️⃣ 📚 📎 📦 🧾 ⚙️ 💖 Kubernete 🛎 ✔️ 🛠️ 🌌 🚚 **🧬 📦** ⏪ 🔗 **📐 ⚖** 📨 📨. 🌐 **🌑 🎚**.
📚 💼, 👆 🔜 🎲 💚 🏗 **☁ 🖼 ⚪️➡️ 🖌** [🔬 🔛](#dockerfile), ❎ 👆 🔗, &amp; 🏃‍♂ **👁 Uvicorn 🛠️** ↩️ 🏃‍♂ 🕳 💖 🐁 ⏮️ Uvicorn 👨‍🏭.
### 📐 ⚙
🕐❔ ⚙️ 📦, 👆 🔜 🛎 ✔️ 🦲 **👂 🔛 👑 ⛴**. ⚫️ 💪 🎲 ➕1️⃣ 📦 👈 **🤝 ❎ 🗳** 🍵 **🇺🇸🔍** ⚖️ 🎏 🧰.
👉 🦲 🔜 ✊ **📐** 📨 &amp; 📎 👈 👪 👨‍🏭 (🤞) **⚖** 🌌, ⚫️ 🛎 🤙 **📐 ⚙**.
!!! tip
🎏 **🤝 ❎ 🗳** 🦲 ⚙️ 🇺🇸🔍 🔜 🎲 **📐 ⚙**.
&amp; 🕐❔ 👷 ⏮️ 📦, 🎏 ⚙️ 👆 ⚙️ ▶️ &amp; 🛠️ 👫 🔜 ⏪ ✔️ 🔗 🧰 📶 **🕸 📻** (✅ 🇺🇸🔍 📨) ⚪️➡️ 👈 **📐 ⚙** (👈 💪 **🤝 ❎ 🗳**) 📦(Ⓜ) ⏮️ 👆 📱.
### 1️⃣ 📐 ⚙ - 💗 👨‍🏭 📦
🕐❔ 👷 ⏮️ **Kubernete** ⚖️ 🎏 📎 📦 🧾 ⚙️, ⚙️ 👫 🔗 🕸 🛠️ 🔜 ✔ 👁 **📐 ⚙** 👈 👂 🔛 👑 **⛴** 📶 📻 (📨) 🎲 **💗 📦** 🏃 👆 📱.
🔠 👫 📦 🏃‍♂ 👆 📱 🔜 🛎 ✔️ **1️⃣ 🛠️** (✅ Uvicorn 🛠️ 🏃 👆 FastAPI 🈸). 👫 🔜 🌐 **🌓 📦**, 🏃‍♂ 🎏 👜, ✋️ 🔠 ⏮️ 🚮 👍 🛠️, 💾, ♒️. 👈 🌌 👆 🔜 ✊ 📈 **🛠️** **🎏 🐚** 💽, ⚖️ **🎏 🎰**.
&amp; 📎 📦 ⚙️ ⏮️ **📐 ⚙** 🔜 **📎 📨** 🔠 1️⃣ 📦 ⏮️ 👆 📱 **🔄**. , 🔠 📨 💪 🍵 1️⃣ 💗 **🔁 📦** 🏃 👆 📱.
&amp; 🛎 👉 **📐 ⚙** 🔜 💪 🍵 📨 👈 🚶 *🎏* 📱 👆 🌑 (✅ 🎏 🆔, ⚖️ 🔽 🎏 📛 ➡ 🔡), &amp; 🔜 📶 👈 📻 ▶️️ 📦 *👈 🎏* 🈸 🏃‍♂ 👆 🌑.
### 1️⃣ 🛠️ 📍 📦
👉 🆎 😐, 👆 🎲 🔜 💚 ✔️ **👁 (Uvicorn) 🛠️ 📍 📦**, 👆 🔜 ⏪ 🚚 🧬 🌑 🎚.
, 👉 💼, 👆 **🔜 🚫** 💚 ✔️ 🛠️ 👨‍💼 💖 🐁 ⏮️ Uvicorn 👨‍🏭, ⚖️ Uvicorn ⚙️ 🚮 👍 Uvicorn 👨‍🏭. 👆 🔜 💚 ✔️ **👁 Uvicorn 🛠️** 📍 📦 (✋️ 🎲 💗 📦).
✔️ ➕1️⃣ 🛠️ 👨‍💼 🔘 📦 (🔜 ⏮️ 🐁 ⚖️ Uvicorn 🛠️ Uvicorn 👨‍🏭) 🔜 🕴 🚮 **🙃 🔀** 👈 👆 🌅 🎲 ⏪ ✊ 💅 ⏮️ 👆 🌑 ⚙️.
### 📦 ⏮️ 💗 🛠️ &amp; 🎁 💼
↗️, 📤 **🎁 💼** 🌐❔ 👆 💪 💚 ✔️ **📦** ⏮️ **🐁 🛠️ 👨‍💼** ▶️ 📚 **Uvicorn 👨‍🏭 🛠️** 🔘.
📚 💼, 👆 💪 ⚙️ **🛂 ☁ 🖼** 👈 🔌 **🐁** 🛠️ 👨‍💼 🏃‍♂ 💗 **Uvicorn 👨‍🏭 🛠️**, &amp; 🔢 ⚒ 🔆 🔢 👨‍🏭 ⚓️ 🔛 ⏮️ 💽 🐚 🔁. 👤 🔜 💬 👆 🌅 🔃 ⚫️ 🔛 [🛂 ☁ 🖼 ⏮️ 🐁 - Uvicorn](#official-docker-image-with-gunicorn-uvicorn).
📥 🖼 🕐❔ 👈 💪 ⚒ 🔑:
#### 🙅 📱
👆 💪 💚 🛠️ 👨‍💼 📦 🚥 👆 🈸 **🙅 🥃** 👈 👆 🚫 💪 (🐥 🚫) 👌-🎶 🔢 🛠️ 💁‍♂️ 🌅, &amp; 👆 💪 ⚙️ 🏧 🔢 (⏮️ 🛂 ☁ 🖼), &amp; 👆 🏃‍♂ ⚫️ 🔛 **👁 💽**, 🚫 🌑.
#### ☁ ✍
👆 💪 🛠️ **👁 💽** (🚫 🌑) ⏮️ **☁ ✍**, 👆 🚫🔜 ✔️ ⏩ 🌌 🛠️ 🧬 📦 (⏮️ ☁ ✍) ⏪ 🛡 🔗 🕸 &amp; **📐 ⚖**.
⤴️ 👆 💪 💚 ✔️ **👁 📦** ⏮️ **🛠️ 👨‍💼** ▶️ **📚 👨‍🏭 🛠️** 🔘.
#### 🤴 &amp; 🎏 🤔
👆 💪 ✔️ **🎏 🤔** 👈 🔜 ⚒ ⚫️ ⏩ ✔️ **👁 📦** ⏮️ **💗 🛠️** ↩️ ✔️ **💗 📦** ⏮️ **👁 🛠️** 🔠 👫.
🖼 (🪀 🔛 👆 🖥) 👆 💪 ✔️ 🧰 💖 🤴 🏭 🎏 📦 👈 🔜 ✔️ 🔐 **🔠 📨** 👈 👟.
👉 💼, 🚥 👆 ✔️ **💗 📦**, 🔢, 🕐❔ 🤴 👟 **✍ ⚖**, ⚫️ 🔜 🤚 🕐 **👁 📦 🔠 🕰** (📦 👈 🍵 👈 🎯 📨), ↩️ 🤚 **📈 ⚖** 🌐 🔁 📦.
⤴️, 👈 💼, ⚫️ 💪 🙅 ✔️ **1️⃣ 📦** ⏮️ **💗 🛠️**, &amp; 🇧🇿 🧰 (✅ 🤴 🏭) 🔛 🎏 📦 📈 🤴 ⚖ 🌐 🔗 🛠️ &amp; 🎦 👈 ⚖ 🔛 👈 👁 📦.
---
👑 ☝, **👌** 👉 **🚫 ✍ 🗿** 👈 👆 ✔️ 😄 ⏩. 👆 💪 ⚙️ 👫 💭 **🔬 👆 👍 ⚙️ 💼** &amp; 💭 ⚫️❔ 👍 🎯 👆 ⚙️, ✅ 👅 ❔ 🛠️ 🔧:
* 💂‍♂ - 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* 🧬 (🔢 🛠️ 🏃)
* 💾
* ⏮️ 🔁 ⏭ ▶️
## 💾
🚥 👆 🏃 **👁 🛠️ 📍 📦** 👆 🔜 ✔️ 🌅 ⚖️ 🌘 👍-🔬, ⚖, &amp; 📉 💸 💾 🍴 🔠 👈 📦 (🌅 🌘 1️⃣ 🚥 👫 🔁).
&amp; ⤴️ 👆 💪 ⚒ 👈 🎏 💾 📉 &amp; 📄 👆 📳 👆 📦 🧾 ⚙️ (🖼 **Kubernete**). 👈 🌌 ⚫️ 🔜 💪 **🔁 📦** **💪 🎰** ✊ 🔘 🏧 💸 💾 💪 👫, &amp; 💸 💪 🎰 🌑.
🚥 👆 🈸 **🙅**, 👉 🔜 🎲 **🚫 ⚠**, &amp; 👆 💪 🚫 💪 ✔ 🏋️ 💾 📉. ✋️ 🚥 👆 **⚙️ 📚 💾** (🖼 ⏮️ **🎰 🏫** 🏷), 👆 🔜 ✅ ❔ 🌅 💾 👆 😩 &amp; 🔆 **🔢 📦** 👈 🏃 **🔠 🎰** (&amp; 🎲 🚮 🌖 🎰 👆 🌑).
🚥 👆 🏃 **💗 🛠️ 📍 📦** (🖼 ⏮️ 🛂 ☁ 🖼) 👆 🔜 ✔️ ⚒ 💭 👈 🔢 🛠️ ▶️ 🚫 **🍴 🌖 💾** 🌘 ⚫️❔ 💪.
## ⏮️ 🔁 ⏭ ▶️ &amp; 📦
🚥 👆 ⚙️ 📦 (✅ ☁, Kubernete), ⤴️ 📤 2️⃣ 👑 🎯 👆 💪 ⚙️.
### 💗 📦
🚥 👆 ✔️ **💗 📦**, 🎲 🔠 1️⃣ 🏃 **👁 🛠️** (🖼, **Kubernete** 🌑), ⤴️ 👆 🔜 🎲 💚 ✔️ **🎏 📦** 🔨 👷 **⏮️ 📶** 👁 📦, 🏃 👁 🛠️, **⏭** 🏃 🔁 👨‍🏭 📦.
!!! info
🚥 👆 ⚙️ Kubernete, 👉 🔜 🎲 <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" class="external-link" target="_blank">🕑 📦</a>.
🚥 👆 ⚙️ 💼 📤 🙅‍♂ ⚠ 🏃‍♂ 👈 ⏮️ 📶 **💗 🕰 🔗** (🖼 🚥 👆 🚫 🏃 💽 🛠️, ✋️ ✅ 🚥 💽 🔜), ⤴️ 👆 💪 🚮 👫 🔠 📦 ▶️️ ⏭ ▶️ 👑 🛠️.
### 👁 📦
🚥 👆 ✔️ 🙅 🖥, ⏮️ **👁 📦** 👈 ⤴️ ▶️ 💗 **👨‍🏭 🛠️** (⚖️ 1️⃣ 🛠️), ⤴️ 👆 💪 🏃 👈 ⏮️ 🔁 🎏 📦, ▶️️ ⏭ ▶️ 🛠️ ⏮️ 📱. 🛂 ☁ 🖼 🐕‍🦺 👉 🔘.
## 🛂 ☁ 🖼 ⏮️ 🐁 - Uvicorn
📤 🛂 ☁ 🖼 👈 🔌 🐁 🏃‍♂ ⏮️ Uvicorn 👨‍🏭, ℹ ⏮️ 📃: [💽 👨‍🏭 - 🐁 ⏮️ Uvicorn](./server-workers.md){.internal-link target=_blank}.
👉 🖼 🔜 ⚠ ✴️ ⚠ 🔬 🔛: [📦 ⏮️ 💗 🛠️ &amp; 🎁 💼](#containers-with-multiple-processes-and-special-cases).
* <a href="https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker" class="external-link" target="_blank">tiangolo/uvicorn-🐁-fastapi</a>.
!!! warning
📤 ↕ 🤞 👈 👆 **🚫** 💪 👉 🧢 🖼 ⚖️ 🙆 🎏 🎏 1️⃣, &amp; 🔜 👻 📆 🏗 🖼 ⚪️➡️ 🖌 [🔬 🔛: 🏗 ☁ 🖼 FastAPI](#build-a-docker-image-for-fastapi).
👉 🖼 ✔️ **🚘-📳** 🛠️ 🔌 ⚒ **🔢 👨‍🏭 🛠️** ⚓️ 🔛 💽 🐚 💪.
⚫️ ✔️ **🤔 🔢**, ✋️ 👆 💪 🔀 &amp; ℹ 🌐 📳 ⏮️ **🌐 🔢** ⚖️ 📳 📁.
⚫️ 🐕‍🦺 🏃 <a href="https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker#pre_start_path" class="external-link" target="_blank">**⏮️ 🔁 ⏭ ▶️**</a> ⏮️ ✍.
!!! tip
👀 🌐 📳 &amp; 🎛, 🚶 ☁ 🖼 📃: <a href="https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker" class="external-link" target="_blank">Tiangolo/uvicorn-🐁-fastapi</a>.
### 🔢 🛠️ 🔛 🛂 ☁ 🖼
**🔢 🛠️** 🔛 👉 🖼 **📊 🔁** ⚪️➡️ 💽 **🐚** 💪.
👉 ⛓ 👈 ⚫️ 🔜 🔄 **🗜** 🌅 **🎭** ⚪️➡️ 💽 💪.
👆 💪 🔆 ⚫️ ⏮️ 📳 ⚙️ **🌐 🔢**, ♒️.
✋️ ⚫️ ⛓ 👈 🔢 🛠️ 🪀 🔛 💽 📦 🏃, **💸 💾 🍴** 🔜 🪀 🔛 👈.
, 🚥 👆 🈸 🍴 📚 💾 (🖼 ⏮️ 🎰 🏫 🏷), &amp; 👆 💽 ✔️ 📚 💽 🐚 **✋️ 🐥 💾**, ⤴️ 👆 📦 💪 🔚 🆙 🔄 ⚙️ 🌅 💾 🌘 ⚫️❔ 💪, &amp; 🤕 🎭 📚 (⚖️ 💥). 👶
### ✍ `Dockerfile`
📥 ❔ 👆 🔜 ✍ `Dockerfile` ⚓️ 🔛 👉 🖼:
```Dockerfile
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
COPY ./app /app
```
### 🦏 🈸
🚥 👆 ⏩ 📄 🔃 🏗 [🦏 🈸 ⏮️ 💗 📁](../tutorial/bigger-applications.md){.internal-link target=_blank}, 👆 `Dockerfile` 💪 ↩️ 👀 💖:
```Dockerfile hl_lines="7"
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
COPY ./app /app/app
```
### 🕐❔ ⚙️
👆 🔜 🎲 **🚫** ⚙️ 👉 🛂 🧢 🖼 (⚖️ 🙆 🎏 🎏 1️⃣) 🚥 👆 ⚙️ **Kubernete** (⚖️ 🎏) &amp; 👆 ⏪ ⚒ **🧬** 🌑 🎚, ⏮️ 💗 **📦**. 📚 💼, 👆 👍 📆 **🏗 🖼 ⚪️➡️ 🖌** 🔬 🔛: [🏗 ☁ 🖼 FastAPI](#build-a-docker-image-for-fastapi).
👉 🖼 🔜 ⚠ ✴️ 🎁 💼 🔬 🔛 [📦 ⏮️ 💗 🛠️ &amp; 🎁 💼](#containers-with-multiple-processes-and-special-cases). 🖼, 🚥 👆 🈸 **🙅 🥃** 👈 ⚒ 🔢 🔢 🛠️ ⚓️ 🔛 💽 👷 👍, 👆 🚫 💚 😥 ⏮️ ❎ 🛠️ 🧬 🌑 🎚, &amp; 👆 🚫 🏃 🌅 🌘 1️⃣ 📦 ⏮️ 👆 📱. ⚖️ 🚥 👆 🛠️ ⏮️ **☁ ✍**, 🏃 🔛 👁 💽, ♒️.
## 🛠️ 📦 🖼
⏮️ ✔️ 📦 (☁) 🖼 📤 📚 🌌 🛠️ ⚫️.
🖼:
* ⏮️ **☁ ✍** 👁 💽
* ⏮️ **Kubernete** 🌑
* ⏮️ ☁ 🐝 📳 🌑
* ⏮️ ➕1️⃣ 🧰 💖 🖖
* ⏮️ ☁ 🐕‍🦺 👈 ✊ 👆 📦 🖼 &amp; 🛠️ ⚫️
## ☁ 🖼 ⏮️ 🎶
🚥 👆 ⚙️ <a href="https://python-poetry.org/" class="external-link" target="_blank">🎶</a> 🛠️ 👆 🏗 🔗, 👆 💪 ⚙️ ☁ 👁-▶️ 🏗:
```{ .dockerfile .annotate }
# (1)
FROM python:3.9 as requirements-stage
# (2)
WORKDIR /tmp
# (3)
RUN pip install poetry
# (4)
COPY ./pyproject.toml ./poetry.lock* /tmp/
# (5)
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
# (6)
FROM python:3.9
# (7)
WORKDIR /code
# (8)
COPY --from=requirements-stage /tmp/requirements.txt /code/requirements.txt
# (9)
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# (10)
COPY ./app /code/app
# (11)
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
```
1️⃣. 👉 🥇 ▶️, ⚫️ 🌟 `requirements-stage`.
2️⃣. ⚒ `/tmp` ⏮️ 👷 📁.
📥 🌐❔ 👥 🔜 🏗 📁 `requirements.txt`
3️⃣. ❎ 🎶 👉 ☁ ▶️.
4️⃣. 📁 `pyproject.toml` &amp; `poetry.lock` 📁 `/tmp` 📁.
↩️ ⚫️ ⚙️ `./poetry.lock*` (▶️ ⏮️ `*`), ⚫️ 🏆 🚫 💥 🚥 👈 📁 🚫 💪.
5️⃣. 🏗 `requirements.txt` 📁.
6️⃣. 👉 🏁 ▶️, 🕳 📥 🔜 🛡 🏁 📦 🖼.
7️⃣. ⚒ ⏮️ 👷 📁 `/code`.
8️⃣. 📁 `requirements.txt` 📁 `/code` 📁.
👉 📁 🕴 🖖 ⏮️ ☁ ▶️, 👈 ⚫️❔ 👥 ⚙️ `--from-requirements-stage` 📁 ⚫️.
9️⃣. ❎ 📦 🔗 🏗 `requirements.txt` 📁.
1️⃣0️⃣. 📁 `app` 📁 `/code` 📁.
1️⃣1️⃣. 🏃 `uvicorn` 📋, 💬 ⚫️ ⚙️ `app` 🎚 🗄 ⚪️➡️ `app.main`.
!!! tip
🖊 💭 🔢 👀 ⚫️❔ 🔠 ⏸ 🔨.
**☁ ▶️** 🍕 `Dockerfile` 👈 👷 **🍕 📦 🖼** 👈 🕴 ⚙️ 🏗 📁 ⚙️ ⏪.
🥇 ▶️ 🔜 🕴 ⚙️ **❎ 🎶** &amp; **🏗 `requirements.txt`** ⏮️ 👆 🏗 🔗 ⚪️➡️ 🎶 `pyproject.toml` 📁.
👉 `requirements.txt` 📁 🔜 ⚙️ ⏮️ `pip`**⏭ ▶️**.
🏁 📦 🖼 **🕴 🏁 ▶️** 🛡. ⏮️ ▶️(Ⓜ) 🔜 ❎.
🕐❔ ⚙️ 🎶, ⚫️ 🔜 ⚒ 🔑 ⚙️ **☁ 👁-▶️ 🏗** ↩️ 👆 🚫 🤙 💪 ✔️ 🎶 &amp; 🚮 🔗 ❎ 🏁 📦 🖼, 👆 **🕴 💪** ✔️ 🏗 `requirements.txt` 📁 ❎ 👆 🏗 🔗.
⤴️ ⏭ (&amp; 🏁) ▶️ 👆 🔜 🏗 🖼 🌅 ⚖️ 🌘 🎏 🌌 🔬 ⏭.
### ⛅ 🤝 ❎ 🗳 - 🎶
🔄, 🚥 👆 🏃‍♂ 👆 📦 ⛅ 🤝 ❎ 🗳 (📐 ⚙) 💖 👌 ⚖️ Traefik, 🚮 🎛 `--proxy-headers` 📋:
```Dockerfile
CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]
```
## 🌃
⚙️ 📦 ⚙️ (✅ ⏮️ **☁** &amp; **Kubernete**) ⚫️ ▶️️ 📶 🎯 🍵 🌐 **🛠️ 🔧**:
* 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* 🧬 (🔢 🛠️ 🏃)
* 💾
* ⏮️ 🔁 ⏭ ▶️
🌅 💼, 👆 🎲 🏆 🚫 💚 ⚙️ 🙆 🧢 🖼, &amp; ↩️ **🏗 📦 🖼 ⚪️➡️ 🖌** 1️⃣ ⚓️ 🔛 🛂 🐍 ☁ 🖼.
✊ 💅 **✔** 👩‍🌾 `Dockerfile` &amp; **☁ 💾** 👆 💪 **📉 🏗 🕰**, 📉 👆 📈 (&amp; ❎ 😩). 👶
🎯 🎁 💼, 👆 💪 💚 ⚙️ 🛂 ☁ 🖼 FastAPI. 👶

190
docs/em/docs/deployment/https.md

@ -0,0 +1,190 @@
# 🔃 🇺🇸🔍
⚫️ ⏩ 🤔 👈 🇺🇸🔍 🕳 👈 "🛠️" ⚖️ 🚫.
✋️ ⚫️ 🌌 🌖 🏗 🌘 👈.
!!! tip
🚥 👆 🏃 ⚖️ 🚫 💅, 😣 ⏮️ ⏭ 📄 🔁 🔁 👩‍🌾 ⚒ 🌐 🆙 ⏮️ 🎏 ⚒.
**💡 🔰 🇺🇸🔍**, ⚪️➡️ 🏬 🤔, ✅ <a href="https://howhttps.works/" class="external-link" target="_blank">https://howhttps.works/</a>.
🔜, ⚪️➡️ **👩‍💻 🤔**, 📥 📚 👜 ✔️ 🤯 ⏪ 💭 🔃 🇺🇸🔍:
* 🇺🇸🔍, **💽** 💪 **✔️ "📄"** 🏗 **🥉 🥳**.
* 📚 📄 🤙 **🏆** ⚪️➡️ 🥉 🥳, 🚫 "🏗".
* 📄 ✔️ **1️⃣2️⃣🗓️**.
* 👫 **🕛**.
* &amp; ⤴️ 👫 💪 **♻**, **🏆 🔄** ⚪️➡️ 🥉 🥳.
* 🔐 🔗 🔨 **🕸 🎚**.
* 👈 1️⃣ 🧽 **🔛 🇺🇸🔍**.
* , **📄 &amp; 🔐** 🍵 🔨 **⏭ 🇺🇸🔍**.
* **🕸 🚫 💭 🔃 "🆔"**. 🕴 🔃 📢 📢.
* ℹ 🔃 **🎯 🆔** 📨 🚶 **🇺🇸🔍 💽**.
* **🇺🇸🔍 📄** "✔" **🎯 🆔**, ✋️ 🛠️ &amp; 🔐 🔨 🕸 🎚, **⏭ 💭** ❔ 🆔 ➖ 🙅 ⏮️.
* **🔢**, 👈 🔜 ⛓ 👈 👆 💪 🕴 ✔️ **1️⃣ 🇺🇸🔍 📄 📍 📢 📢**.
* 🙅‍♂ 🤔 ❔ 🦏 👆 💽 ⚖️ ❔ 🤪 🔠 🈸 👆 ✔️ 🔛 ⚫️ 💪.
* 📤 **⚗** 👉, 👐.
* 📤 **↔** **🤝** 🛠️ (1️⃣ 🚚 🔐 🕸 🎚, ⏭ 🇺🇸🔍) 🤙 **<a href="https://en.wikipedia.org/wiki/Server_Name_Indication" class="external-link" target="_blank"><abbr title="Server Name Indication">👲</abbr></a>**.
* 👉 👲 ↔ ✔ 1️⃣ 👁 💽 (⏮️ **👁 📢 📢**) ✔️ **📚 🇺🇸🔍 📄** &amp; 🍦 **💗 🇺🇸🔍 🆔/🈸**.
* 👉 👷, **👁** 🦲 (📋) 🏃 🔛 💽, 👂 🔛 **📢 📢 📢**, 🔜 ✔️ **🌐 🇺🇸🔍 📄** 💽.
* **⏮️** 🏆 🔐 🔗, 📻 🛠️ **🇺🇸🔍**.
* 🎚 **🗜**, ✋️ 👫 ➖ 📨 ⏮️ **🇺🇸🔍 🛠️**.
⚫️ ⚠ 💡 ✔️ **1️⃣ 📋/🇺🇸🔍 💽** 🏃 🔛 💽 (🎰, 🦠, ♒️.) &amp; **🛠️ 🌐 🇺🇸🔍 🍕**: 📨 **🗜 🇺🇸🔍 📨**, 📨 **🗜 🇺🇸🔍 📨** ☑ 🇺🇸🔍 🈸 🏃 🎏 💽 ( **FastAPI** 🈸, 👉 💼), ✊ **🇺🇸🔍 📨** ⚪️➡️ 🈸, **🗜 ⚫️** ⚙️ ☑ **🇺🇸🔍 📄** &amp; 📨 ⚫️ 🔙 👩‍💻 ⚙️ **🇺🇸🔍**. 👉 💽 🛎 🤙 **<a href="https://en.wikipedia.org/wiki/TLS_termination_proxy" class="external-link" target="_blank">🤝 ❎ 🗳</a>**.
🎛 👆 💪 ⚙️ 🤝 ❎ 🗳:
* Traefik (👈 💪 🍵 📄 🔕)
* 📥 (👈 💪 🍵 📄 🔕)
* 👌
* ✳
## ➡️ 🗜
⏭ ➡️ 🗜, 👫 **🇺🇸🔍 📄** 💲 💙 🥉 🥳.
🛠️ 📎 1️⃣ 👫 📄 ⚙️ ⚠, 🚚 📠 &amp; 📄 😥.
✋️ ⤴️ **<a href="https://letsencrypt.org/" class="external-link" target="_blank">➡️ 🗜</a>** ✍.
⚫️ 🏗 ⚪️➡️ 💾 🏛. ⚫️ 🚚 **🇺🇸🔍 📄 🆓**, 🏧 🌌. 👫 📄 ⚙️ 🌐 🐩 🔐 💂‍♂, &amp; 📏-🖖 (🔃 3️⃣ 🗓️), **💂‍♂ 🤙 👍** ↩️ 👫 📉 🔆.
🆔 🔐 ✔ &amp; 📄 🏗 🔁. 👉 ✔ 🏧 🔕 👫 📄.
💭 🏧 🛠️ &amp; 🔕 👫 📄 👈 👆 💪 ✔️ **🔐 🇺🇸🔍, 🆓, ♾**.
## 🇺🇸🔍 👩‍💻
📥 🖼 ❔ 🇺🇸🔍 🛠️ 💪 👀 💖, 🔁 🔁, 💸 🙋 ✴️ 💭 ⚠ 👩‍💻.
### 🆔 📛
⚫️ 🔜 🎲 🌐 ▶️ 👆 **🏗** **🆔 📛**. ⤴️, 👆 🔜 🔗 ⚫️ 🏓 💽 (🎲 👆 🎏 ☁ 🐕‍🦺).
👆 🔜 🎲 🤚 ☁ 💽 (🕹 🎰) ⚖️ 🕳 🎏, &amp; ⚫️ 🔜 ✔️ <abbr title="That doesn't change">🔧</abbr> **📢 📢 📢**.
🏓 💽(Ⓜ) 👆 🔜 🔗 ⏺ ("`A record`") ☝ **👆 🆔** 📢 **📢 📢 👆 💽**.
👆 🔜 🎲 👉 🕐, 🥇 🕰, 🕐❔ ⚒ 🌐 🆙.
!!! tip
👉 🆔 📛 🍕 🌌 ⏭ 🇺🇸🔍, ✋️ 🌐 🪀 🔛 🆔 &amp; 📢 📢, ⚫️ 💸 💬 ⚫️ 📥.
### 🏓
🔜 ➡️ 🎯 🔛 🌐 ☑ 🇺🇸🔍 🍕.
🥇, 🖥 🔜 ✅ ⏮️ **🏓 💽** ⚫️❔ **📢 🆔**, 👉 💼, `someapp.example.com`.
🏓 💽 🔜 💬 🖥 ⚙️ 🎯 **📢 📢**. 👈 🔜 📢 📢 📢 ⚙️ 👆 💽, 👈 👆 🔗 🏓 💽.
<img src="/img/deployment/https/https01.svg">
### 🤝 🤝 ▶️
🖥 🔜 ⤴️ 🔗 ⏮️ 👈 📢 📢 🔛 **⛴ 4️⃣4️⃣3️⃣** (🇺🇸🔍 ⛴).
🥇 🍕 📻 🛠️ 🔗 🖖 👩‍💻 &amp; 💽 &amp; 💭 🔐 🔑 👫 🔜 ⚙️, ♒️.
<img src="/img/deployment/https/https02.svg">
👉 🔗 🖖 👩‍💻 &amp; 💽 🛠️ 🤝 🔗 🤙 **🤝 🤝**.
### 🤝 ⏮️ 👲 ↔
**🕴 1️⃣ 🛠️** 💽 💪 👂 🔛 🎯 **⛴** 🎯 **📢 📢**. 📤 💪 🎏 🛠️ 👂 🔛 🎏 ⛴ 🎏 📢 📢, ✋️ 🕴 1️⃣ 🔠 🌀 📢 📢 &amp; ⛴.
🤝 (🇺🇸🔍) ⚙️ 🎯 ⛴ `443` 🔢. 👈 ⛴ 👥 🔜 💪.
🕴 1️⃣ 🛠️ 💪 👂 🔛 👉 ⛴, 🛠️ 👈 🔜 ⚫️ 🔜 **🤝 ❎ 🗳**.
🤝 ❎ 🗳 🔜 ✔️ 🔐 1️⃣ ⚖️ 🌅 **🤝 📄** (🇺🇸🔍 📄).
⚙️ **👲 ↔** 🔬 🔛, 🤝 ❎ 🗳 🔜 ✅ ❔ 🤝 (🇺🇸🔍) 📄 💪 ⚫️ 🔜 ⚙️ 👉 🔗, ⚙️ 1️⃣ 👈 🏏 🆔 📈 👩‍💻.
👉 💼, ⚫️ 🔜 ⚙️ 📄 `someapp.example.com`.
<img src="/img/deployment/https/https03.svg">
👩‍💻 ⏪ **💙** 👨‍💼 👈 🏗 👈 🤝 📄 (👉 💼 ➡️ 🗜, ✋️ 👥 🔜 👀 🔃 👈 ⏪), ⚫️ 💪 **✔** 👈 📄 ☑.
⤴️, ⚙️ 📄, 👩‍💻 &amp; 🤝 ❎ 🗳 **💭 ❔ 🗜** 🎂 **🕸 📻**. 👉 🏁 **🤝 🤝** 🍕.
⏮️ 👉, 👩‍💻 &amp; 💽 ✔️ **🗜 🕸 🔗**, 👉 ⚫️❔ 🤝 🚚. &amp; ⤴️ 👫 💪 ⚙️ 👈 🔗 ▶️ ☑ **🇺🇸🔍 📻**.
&amp; 👈 ⚫️❔ **🇺🇸🔍** , ⚫️ ✅ **🇺🇸🔍** 🔘 **🔐 🤝 🔗** ↩️ 😁 (💽) 🕸 🔗.
!!! tip
👀 👈 🔐 📻 🔨 **🕸 🎚**, 🚫 🇺🇸🔍 🎚.
### 🇺🇸🔍 📨
🔜 👈 👩‍💻 &amp; 💽 (🎯 🖥 &amp; 🤝 ❎ 🗳) ✔️ **🗜 🕸 🔗**, 👫 💪 ▶️ **🇺🇸🔍 📻**.
, 👩‍💻 📨 **🇺🇸🔍 📨**. 👉 🇺🇸🔍 📨 🔘 🗜 🤝 🔗.
<img src="/img/deployment/https/https04.svg">
### 🗜 📨
🤝 ❎ 🗳 🔜 ⚙️ 🔐 ✔ **🗜 📨**, &amp; 🔜 📶 **✅ (🗜) 🇺🇸🔍 📨** 🛠️ 🏃 🈸 (🖼 🛠️ ⏮️ Uvicorn 🏃‍♂ FastAPI 🈸).
<img src="/img/deployment/https/https05.svg">
### 🇺🇸🔍 📨
🈸 🔜 🛠️ 📨 &amp; 📨 **✅ (💽) 🇺🇸🔍 📨** 🤝 ❎ 🗳.
<img src="/img/deployment/https/https06.svg">
### 🇺🇸🔍 📨
🤝 ❎ 🗳 🔜 ⤴️ **🗜 📨** ⚙️ ⚛ ✔ ⏭ (👈 ▶️ ⏮️ 📄 `someapp.example.com`), &amp; 📨 ⚫️ 🔙 🖥.
⏭, 🖥 🔜 ✔ 👈 📨 ☑ &amp; 🗜 ⏮️ ▶️️ 🔐 🔑, ♒️. ⚫️ 🔜 ⤴️ **🗜 📨** &amp; 🛠️ ⚫️.
<img src="/img/deployment/https/https07.svg">
👩‍💻 (🖥) 🔜 💭 👈 📨 👟 ⚪️➡️ ☑ 💽 ↩️ ⚫️ ⚙️ ⚛ 👫 ✔ ⚙️ **🇺🇸🔍 📄** ⏭.
### 💗 🈸
🎏 💽 (⚖️ 💽), 📤 💪 **💗 🈸**, 🖼, 🎏 🛠️ 📋 ⚖️ 💽.
🕴 1️⃣ 🛠️ 💪 🚚 🎯 📢 &amp; ⛴ (🤝 ❎ 🗳 👆 🖼) ✋️ 🎏 🈸/🛠️ 💪 🏃 🔛 💽(Ⓜ) 💁‍♂️, 📏 👫 🚫 🔄 ⚙️ 🎏 **🌀 📢 📢 &amp; ⛴**.
<img src="/img/deployment/https/https08.svg">
👈 🌌, 🤝 ❎ 🗳 💪 🍵 🇺🇸🔍 &amp; 📄 **💗 🆔**, 💗 🈸, &amp; ⤴️ 📶 📨 ▶️️ 🈸 🔠 💼.
### 📄 🔕
☝ 🔮, 🔠 📄 🔜 **🕛** (🔃 3️⃣ 🗓️ ⏮️ 🏗 ⚫️).
&amp; ⤴️, 📤 🔜 ➕1️⃣ 📋 (💼 ⚫️ ➕1️⃣ 📋, 💼 ⚫️ 💪 🎏 🤝 ❎ 🗳) 👈 🔜 💬 ➡️ 🗜, &amp; ♻ 📄(Ⓜ).
<img src="/img/deployment/https/https.svg">
**🤝 📄** **🔗 ⏮️ 🆔 📛**, 🚫 ⏮️ 📢 📢.
, ♻ 📄, 🔕 📋 💪 **🎦** 🛃 (➡️ 🗜) 👈 ⚫️ 👐 **"👍" &amp; 🎛 👈 🆔**.
👈, &amp; 🏗 🎏 🈸 💪, 📤 📚 🌌 ⚫️ 💪 ⚫️. 🌟 🌌:
* **🔀 🏓 ⏺**.
* 👉, 🔕 📋 💪 🐕‍🦺 🔗 🏓 🐕‍🦺,, ⚓️ 🔛 🏓 🐕‍🦺 👆 ⚙️, 👉 5️⃣📆 ⚖️ 💪 🚫 🎛.
* **🏃 💽** (🌘 ⏮️ 📄 🛠️ 🛠️) 🔛 📢 📢 📢 🔗 ⏮️ 🆔.
* 👥 💬 🔛, 🕴 1️⃣ 🛠️ 💪 👂 🔛 🎯 📢 &amp; ⛴.
* 👉 1️⃣ 🤔 ⚫️❔ ⚫️ 📶 ⚠ 🕐❔ 🎏 🤝 ❎ 🗳 ✊ 💅 📄 🔕 🛠️.
* ⏪, 👆 💪 ✔️ ⛔️ 🤝 ❎ 🗳 😖, ▶️ 🔕 📋 📎 📄, ⤴️ 🔗 👫 ⏮️ 🤝 ❎ 🗳, &amp; ⤴️ ⏏ 🤝 ❎ 🗳. 👉 🚫 💯, 👆 📱(Ⓜ) 🔜 🚫 💪 ⏮️ 🕰 👈 🤝 ❎ 🗳 📆.
🌐 👉 🔕 🛠️, ⏪ 🍦 📱, 1️⃣ 👑 🤔 ⚫️❔ 👆 🔜 💚 ✔️ **🎏 ⚙️ 🍵 🇺🇸🔍** ⏮️ 🤝 ❎ 🗳 ↩️ ⚙️ 🤝 📄 ⏮️ 🈸 💽 🔗 (✅ Uvicorn).
## 🌃
✔️ **🇺🇸🔍** 📶 ⚠, &amp; **🎯** 🏆 💼. 🌅 🎯 👆 👩‍💻 ✔️ 🚮 🤭 🇺🇸🔍 🔃 **🤔 👉 🔧** &amp; ❔ 👫 👷.
✋️ 🕐 👆 💭 🔰 ℹ **🇺🇸🔍 👩‍💻** 👆 💪 💪 🌀 &amp; 🔗 🎏 🧰 ℹ 👆 🛠️ 🌐 🙅 🌌.
⏭ 📃, 👤 🔜 🎦 👆 📚 🧱 🖼 ❔ ⚒ 🆙 **🇺🇸🔍** **FastAPI** 🈸. 👶

21
docs/em/docs/deployment/index.md

@ -0,0 +1,21 @@
# 🛠️
🛠️ **FastAPI** 🈸 📶 ⏩.
## ⚫️❔ 🔨 🛠️ ⛓
**🛠️** 🈸 ⛓ 🎭 💪 📶 ⚒ ⚫️ **💪 👩‍💻**.
**🕸 🛠️**, ⚫️ 🛎 🔌 🚮 ⚫️ **🛰 🎰**, ⏮️ **💽 📋** 👈 🚚 👍 🎭, ⚖, ♒️, 👈 👆 **👩‍💻** 💪 **🔐** 🈸 ♻ &amp; 🍵 🔁 ⚖️ ⚠.
👉 🔅 **🛠️** ▶️, 🌐❔ 👆 🕧 🔀 📟, 💔 ⚫️ &amp; ♻ ⚫️, ⛔️ &amp; 🔁 🛠️ 💽, ♒️.
## 🛠️ 🎛
📤 📚 🌌 ⚫️ ⚓️ 🔛 👆 🎯 ⚙️ 💼 &amp; 🧰 👈 👆 ⚙️.
👆 💪 **🛠️ 💽** 👆 ⚙️ 🌀 🧰, 👆 💪 ⚙️ **☁ 🐕‍🦺** 👈 🔨 🍕 👷 👆, ⚖️ 🎏 💪 🎛.
👤 🔜 🎦 👆 👑 🔧 👆 🔜 🎲 ✔️ 🤯 🕐❔ 🛠️ **FastAPI** 🈸 (👐 🌅 ⚫️ ✔ 🙆 🎏 🆎 🕸 🈸).
👆 🔜 👀 🌖 ℹ ✔️ 🤯 &amp; ⚒ ⚫️ ⏭ 📄. 👶

145
docs/em/docs/deployment/manually.md

@ -0,0 +1,145 @@
# 🏃 💽 ❎ - Uvicorn
👑 👜 👆 💪 🏃 **FastAPI** 🈸 🛰 💽 🎰 🔫 💽 📋 💖 **Uvicorn**.
📤 3️⃣ 👑 🎛:
* <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>: ↕ 🎭 🔫 💽.
* <a href="https://pgjones.gitlab.io/hypercorn/" class="external-link" target="_blank">Hypercorn</a>: 🔫 💽 🔗 ⏮️ 🇺🇸🔍/2️⃣ &amp; 🎻 👪 🎏 ⚒.
* <a href="https://github.com/django/daphne" class="external-link" target="_blank">👸</a>: 🔫 💽 🏗 ✳ 📻.
## 💽 🎰 &amp; 💽 📋
📤 🤪 ℹ 🔃 📛 ✔️ 🤯. 👶
🔤 "**💽**" 🛎 ⚙️ 🔗 👯‍♂️ 🛰/☁ 💻 (⚛ ⚖️ 🕹 🎰) &amp; 📋 👈 🏃‍♂ 🔛 👈 🎰 (✅ Uvicorn).
✔️ 👈 🤯 🕐❔ 👆 ✍ "💽" 🏢, ⚫️ 💪 🔗 1️⃣ 📚 2️⃣ 👜.
🕐❔ 🔗 🛰 🎰, ⚫️ ⚠ 🤙 ⚫️ **💽**, ✋️ **🎰**, **💾** (🕹 🎰), **🕸**. 👈 🌐 🔗 🆎 🛰 🎰, 🛎 🏃‍♂ 💾, 🌐❔ 👆 🏃 📋.
## ❎ 💽 📋
👆 💪 ❎ 🔫 🔗 💽 ⏮️:
=== "Uvicorn"
* <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>, 🌩-⏩ 🔫 💽, 🏗 🔛 uvloop &amp; httptool.
<div class="termy">
```console
$ pip install "uvicorn[standard]"
---> 100%
```
</div>
!!! tip
`standard`, Uvicorn 🔜 ❎ &amp; ⚙️ 👍 ➕ 🔗.
👈 ✅ `uvloop`, ↕-🎭 💧-♻ `asyncio`, 👈 🚚 🦏 🛠️ 🎭 📈.
=== "Hypercorn"
* <a href="https://gitlab.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>, 🔫 💽 🔗 ⏮️ 🇺🇸🔍/2️⃣.
<div class="termy">
```console
$ pip install hypercorn
---> 100%
```
</div>
...⚖️ 🙆 🎏 🔫 💽.
## 🏃 💽 📋
👆 💪 ⤴️ 🏃 👆 🈸 🎏 🌌 👆 ✔️ ⌛ 🔰, ✋️ 🍵 `--reload` 🎛, ✅:
=== "Uvicorn"
<div class="termy">
```console
$ uvicorn main:app --host 0.0.0.0 --port 80
<span style="color: green;">INFO</span>: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
```
</div>
=== "Hypercorn"
<div class="termy">
```console
$ hypercorn main:app --bind 0.0.0.0:80
Running on 0.0.0.0:8080 over http (CTRL + C to quit)
```
</div>
!!! warning
💭 ❎ `--reload` 🎛 🚥 👆 ⚙️ ⚫️.
`--reload` 🎛 🍴 🌅 🌅 ℹ, 🌅 ⚠, ♒️.
⚫️ ℹ 📚 ⏮️ **🛠️**, ✋️ 👆 **🚫🔜 🚫** ⚙️ ⚫️ **🏭**.
## Hypercorn ⏮️ 🎻
💃 &amp; **FastAPI** ⚓️ 🔛 <a href="https://anyio.readthedocs.io/en/stable/" class="external-link" target="_blank">AnyIO</a>, ❔ ⚒ 👫 🔗 ⏮️ 👯‍♂️ 🐍 🐩 🗃 <a href="https://docs.python.org/3/library/asyncio-task.html" class="external-link" target="_blank"></a> &amp; <a href="https://trio.readthedocs.io/en/stable/" class="external-link" target="_blank">🎻</a>.
👐, Uvicorn ⏳ 🕴 🔗 ⏮️ ✳, &amp; ⚫️ 🛎 ⚙️ <a href="https://github.com/MagicStack/uvloop" class="external-link" target="_blank">`uvloop`</a>, ↕-🎭 💧-♻ `asyncio`.
✋️ 🚥 👆 💚 🔗 ⚙️ **🎻**, ⤴️ 👆 💪 ⚙️ **Hypercorn** ⚫️ 🐕‍🦺 ⚫️. 👶
### ❎ Hypercorn ⏮️ 🎻
🥇 👆 💪 ❎ Hypercorn ⏮️ 🎻 🐕‍🦺:
<div class="termy">
```console
$ pip install "hypercorn[trio]"
---> 100%
```
</div>
### 🏃 ⏮️ 🎻
⤴️ 👆 💪 🚶‍♀️ 📋 ⏸ 🎛 `--worker-class` ⏮️ 💲 `trio`:
<div class="termy">
```console
$ hypercorn main:app --worker-class trio
```
</div>
&amp; 👈 🔜 ▶️ Hypercorn ⏮️ 👆 📱 ⚙️ 🎻 👩‍💻.
🔜 👆 💪 ⚙️ 🎻 🔘 👆 📱. ⚖️ 👍, 👆 💪 ⚙️ AnyIO, 🚧 👆 📟 🔗 ⏮️ 👯‍♂️ 🎻 &amp; ✳. 👶
## 🛠️ 🔧
👫 🖼 🏃 💽 📋 (📧.Ⓜ Uvicorn), ▶️ **👁 🛠️**, 👂 🔛 🌐 📢 (`0.0.0.0`) 🔛 🔁 ⛴ (✅ `80`).
👉 🔰 💭. ✋️ 👆 🔜 🎲 💚 ✊ 💅 🌖 👜, 💖:
* 💂‍♂ - 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* 🧬 (🔢 🛠️ 🏃)
* 💾
* ⏮️ 🔁 ⏭ ▶️
👤 🔜 💬 👆 🌅 🔃 🔠 👫 🔧, ❔ 💭 🔃 👫, &amp; 🧱 🖼 ⏮️ 🎛 🍵 👫 ⏭ 📃. 👶

178
docs/em/docs/deployment/server-workers.md

@ -0,0 +1,178 @@
# 💽 👨‍🏭 - 🐁 ⏮️ Uvicorn
➡️ ✅ 🔙 👈 🛠️ 🔧 ⚪️➡️ ⏭:
* 💂‍♂ - 🇺🇸🔍
* 🏃‍♂ 🔛 🕴
* ⏏
* **🧬 (🔢 🛠️ 🏃)**
* 💾
* ⏮️ 🔁 ⏭ ▶️
🆙 👉 ☝, ⏮️ 🌐 🔰 🩺, 👆 ✔️ 🎲 🏃‍♂ **💽 📋** 💖 Uvicorn, 🏃‍♂ **👁 🛠️**.
🕐❔ 🛠️ 🈸 👆 🔜 🎲 💚 ✔️ **🧬 🛠️** ✊ 📈 **💗 🐚** &amp; 💪 🍵 🌅 📨.
👆 👀 ⏮️ 📃 🔃 [🛠️ 🔧](./concepts.md){.internal-link target=_blank}, 📤 💗 🎛 👆 💪 ⚙️.
📥 👤 🔜 🎦 👆 ❔ ⚙️ <a href="https://gunicorn.org/" class="external-link" target="_blank">**🐁**</a> ⏮️ **Uvicorn 👨‍🏭 🛠️**.
!!! info
🚥 👆 ⚙️ 📦, 🖼 ⏮️ ☁ ⚖️ Kubernete, 👤 🔜 💬 👆 🌅 🔃 👈 ⏭ 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
🎯, 🕐❔ 🏃 🔛 **Kubernete** 👆 🔜 🎲 **🚫** 💚 ⚙️ 🐁 &amp; ↩️ 🏃 **👁 Uvicorn 🛠️ 📍 📦**, ✋️ 👤 🔜 💬 👆 🔃 ⚫️ ⏪ 👈 📃.
## 🐁 ⏮️ Uvicorn 👨‍🏭
**🐁** ✴️ 🈸 💽 ⚙️ **🇨🇻 🐩**. 👈 ⛓ 👈 🐁 💪 🍦 🈸 💖 🏺 &amp; ✳. 🐁 ⚫️ 🚫 🔗 ⏮️ **FastAPI**, FastAPI ⚙️ 🆕 **<a href="https://asgi.readthedocs.io/en/latest/" class="external-link" target="_blank">🔫 🐩</a>**.
✋️ 🐁 🐕‍🦺 👷 **🛠️ 👨‍💼** &amp; 🤝 👩‍💻 💬 ⚫️ ❔ 🎯 **👨‍🏭 🛠️ 🎓** ⚙️. ⤴️ 🐁 🔜 ▶️ 1️⃣ ⚖️ 🌖 **👨‍🏭 🛠️** ⚙️ 👈 🎓.
&amp; **Uvicorn** ✔️ **🐁-🔗 👨‍🏭 🎓**.
⚙️ 👈 🌀, 🐁 🔜 🚫 **🛠️ 👨‍💼**, 👂 🔛 **⛴** &amp; **📢**. &amp; ⚫️ 🔜 **📶** 📻 👨‍🏭 🛠️ 🏃 **Uvicorn 🎓**.
&amp; ⤴️ 🐁-🔗 **Uvicorn 👨‍🏭** 🎓 🔜 🈚 🏭 📊 📨 🐁 🔫 🐩 FastAPI ⚙️ ⚫️.
## ❎ 🐁 &amp; Uvicorn
<div class="termy">
```console
$ pip install "uvicorn[standard]" gunicorn
---> 100%
```
</div>
👈 🔜 ❎ 👯‍♂️ Uvicorn ⏮️ `standard` ➕ 📦 (🤚 ↕ 🎭) &amp; 🐁.
## 🏃 🐁 ⏮️ Uvicorn 👨‍🏭
⤴️ 👆 💪 🏃 🐁 ⏮️:
<div class="termy">
```console
$ gunicorn main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:80
[19499] [INFO] Starting gunicorn 20.1.0
[19499] [INFO] Listening at: http://0.0.0.0:80 (19499)
[19499] [INFO] Using worker: uvicorn.workers.UvicornWorker
[19511] [INFO] Booting worker with pid: 19511
[19513] [INFO] Booting worker with pid: 19513
[19514] [INFO] Booting worker with pid: 19514
[19515] [INFO] Booting worker with pid: 19515
[19511] [INFO] Started server process [19511]
[19511] [INFO] Waiting for application startup.
[19511] [INFO] Application startup complete.
[19513] [INFO] Started server process [19513]
[19513] [INFO] Waiting for application startup.
[19513] [INFO] Application startup complete.
[19514] [INFO] Started server process [19514]
[19514] [INFO] Waiting for application startup.
[19514] [INFO] Application startup complete.
[19515] [INFO] Started server process [19515]
[19515] [INFO] Waiting for application startup.
[19515] [INFO] Application startup complete.
```
</div>
➡️ 👀 ⚫️❔ 🔠 👈 🎛 ⛓:
* `main:app`: 👉 🎏 ❕ ⚙️ Uvicorn, `main` ⛓ 🐍 🕹 📛 "`main`",, 📁 `main.py`. &amp; `app` 📛 🔢 👈 **FastAPI** 🈸.
* 👆 💪 🌈 👈 `main:app` 🌓 🐍 `import` 📄 💖:
```Python
from main import app
```
* , ❤ `main:app` 🔜 🌓 🐍 `import` 🍕 `from main import app`.
* `--workers`: 🔢 👨‍🏭 🛠️ ⚙️, 🔠 🔜 🏃 Uvicorn 👨‍🏭, 👉 💼, 4️⃣ 👨‍🏭.
* `--worker-class`: 🐁-🔗 👨‍🏭 🎓 ⚙️ 👨‍🏭 🛠️.
* 📥 👥 🚶‍♀️ 🎓 👈 🐁 💪 🗄 &amp; ⚙️ ⏮️:
```Python
import uvicorn.workers.UvicornWorker
```
* `--bind`: 👉 💬 🐁 📢 &amp; ⛴ 👂, ⚙️ ❤ (`:`) 🎏 📢 &amp; ⛴.
* 🚥 👆 🏃‍♂ Uvicorn 🔗, ↩️ `--bind 0.0.0.0:80` (🐁 🎛) 👆 🔜 ⚙️ `--host 0.0.0.0` &amp; `--port 80`.
🔢, 👆 💪 👀 👈 ⚫️ 🎦 **🕹** (🛠️ 🆔) 🔠 🛠️ (⚫️ 🔢).
👆 💪 👀 👈:
* 🐁 **🛠️ 👨‍💼** ▶️ ⏮️ 🕹 `19499` (👆 💼 ⚫️ 🔜 🎏 🔢).
* ⤴️ ⚫️ ▶️ `Listening at: http://0.0.0.0:80`.
* ⤴️ ⚫️ 🔍 👈 ⚫️ ✔️ ⚙️ 👨‍🏭 🎓 `uvicorn.workers.UvicornWorker`.
* &amp; ⤴️ ⚫️ ▶️ **4️⃣ 👨‍🏭**, 🔠 ⏮️ 🚮 👍 🕹: `19511`, `19513`, `19514`, &amp; `19515`.
🐁 🔜 ✊ 💅 🛠️ **☠️ 🛠️** &amp; **🔁** 🆕 🕐 🚥 💚 🚧 🔢 👨‍🏭. 👈 ℹ 🍕 ⏮️ **⏏** 🔧 ⚪️➡️ 📇 🔛.
👐, 👆 🔜 🎲 💚 ✔️ 🕳 🏞 ⚒ 💭 **⏏ 🐁** 🚥 💪, &amp; **🏃 ⚫️ 🔛 🕴**, ♒️.
## Uvicorn ⏮️ 👨‍🏭
Uvicorn ✔️ 🎛 ▶️ &amp; 🏃 📚 **👨‍🏭 🛠️**.
👐, 🔜, Uvicorn 🛠️ 🚚 👨‍🏭 🛠️ 🌅 📉 🌘 🐁. , 🚥 👆 💚 ✔️ 🛠️ 👨‍💼 👉 🎚 (🐍 🎚), ⤴️ ⚫️ 💪 👍 🔄 ⏮️ 🐁 🛠️ 👨‍💼.
🙆 💼, 👆 🔜 🏃 ⚫️ 💖 👉:
<div class="termy">
```console
$ uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4
<font color="#A6E22E">INFO</font>: Uvicorn running on <b>http://0.0.0.0:8080</b> (Press CTRL+C to quit)
<font color="#A6E22E">INFO</font>: Started parent process [<font color="#A1EFE4"><b>27365</b></font>]
<font color="#A6E22E">INFO</font>: Started server process [<font color="#A1EFE4">27368</font>]
<font color="#A6E22E">INFO</font>: Waiting for application startup.
<font color="#A6E22E">INFO</font>: Application startup complete.
<font color="#A6E22E">INFO</font>: Started server process [<font color="#A1EFE4">27369</font>]
<font color="#A6E22E">INFO</font>: Waiting for application startup.
<font color="#A6E22E">INFO</font>: Application startup complete.
<font color="#A6E22E">INFO</font>: Started server process [<font color="#A1EFE4">27370</font>]
<font color="#A6E22E">INFO</font>: Waiting for application startup.
<font color="#A6E22E">INFO</font>: Application startup complete.
<font color="#A6E22E">INFO</font>: Started server process [<font color="#A1EFE4">27367</font>]
<font color="#A6E22E">INFO</font>: Waiting for application startup.
<font color="#A6E22E">INFO</font>: Application startup complete.
```
</div>
🕴 🆕 🎛 📥 `--workers` 💬 Uvicorn ▶️ 4️⃣ 👨‍🏭 🛠️.
👆 💪 👀 👈 ⚫️ 🎦 **🕹** 🔠 🛠️, `27365` 👪 🛠️ (👉 **🛠️ 👨‍💼**) &amp; 1️⃣ 🔠 👨‍🏭 🛠️: `27368`, `27369`, `27370`, &amp; `27367`.
## 🛠️ 🔧
📥 👆 👀 ❔ ⚙️ **🐁** (⚖️ Uvicorn) 🛠️ **Uvicorn 👨‍🏭 🛠️** **🔁** 🛠️ 🈸, ✊ 📈 **💗 🐚** 💽, &amp; 💪 🍦 **🌅 📨**.
⚪️➡️ 📇 🛠️ 🔧 ⚪️➡️ 🔛, ⚙️ 👨‍🏭 🔜 ✴️ ℹ ⏮️ **🧬** 🍕, &amp; 🐥 🍖 ⏮️ **⏏**, ✋️ 👆 💪 ✊ 💅 🎏:
* **💂‍♂ - 🇺🇸🔍**
* **🏃‍♂ 🔛 🕴**
* ***⏏***
* 🧬 (🔢 🛠️ 🏃)
* **💾**
* **⏮️ 🔁 ⏭ ▶️**
## 📦 &amp;
⏭ 📃 🔃 [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank} 👤 🔜 💬 🎛 👆 💪 ⚙️ 🍵 🎏 **🛠️ 🔧**.
👤 🔜 🎦 👆 **🛂 ☁ 🖼** 👈 🔌 **🐁 ⏮️ Uvicorn 👨‍🏭** &amp; 🔢 📳 👈 💪 ⚠ 🙅 💼.
📤 👤 🔜 🎦 👆 ❔ **🏗 👆 👍 🖼 ⚪️➡️ 🖌** 🏃 👁 Uvicorn 🛠️ (🍵 🐁). ⚫️ 🙅 🛠️ &amp; 🎲 ⚫️❔ 👆 🔜 💚 🕐❔ ⚙️ 📎 📦 🧾 ⚙️ 💖 **Kubernete**.
## 🌃
👆 💪 ⚙️ **🐁** (⚖️ Uvicorn) 🛠️ 👨‍💼 ⏮️ Uvicorn 👨‍🏭 ✊ 📈 **👁-🐚 💽**, 🏃 **💗 🛠️ 🔗**.
👆 💪 ⚙️ 👉 🧰 &amp; 💭 🚥 👆 ⚒ 🆙 **👆 👍 🛠️ ⚙️** ⏪ ✊ 💅 🎏 🛠️ 🔧 👆.
✅ 👅 ⏭ 📃 💡 🔃 **FastAPI** ⏮️ 📦 (✅ ☁ &amp; Kubernete). 👆 🔜 👀 👈 👈 🧰 ✔️ 🙅 🌌 ❎ 🎏 **🛠️ 🔧** 👍. 👶

87
docs/em/docs/deployment/versions.md

@ -0,0 +1,87 @@
# 🔃 FastAPI ⏬
**FastAPI** ⏪ ➖ ⚙️ 🏭 📚 🈸 &amp; ⚙️. &amp; 💯 💰 🚧 1️⃣0️⃣0️⃣ 💯. ✋️ 🚮 🛠️ 🚚 🔜.
🆕 ⚒ 🚮 🛎, 🐛 🔧 🛎, &amp; 📟 🔁 📉.
👈 ⚫️❔ ⏮️ ⏬ `0.x.x`, 👉 🎨 👈 🔠 ⏬ 💪 ⚠ ✔️ 💔 🔀. 👉 ⏩ <a href="https://semver.org/" class="external-link" target="_blank">⚛ 🛠️</a> 🏛.
👆 💪 ✍ 🏭 🈸 ⏮️ **FastAPI** ▶️️ 🔜 (&amp; 👆 ✔️ 🎲 🔨 ⚫️ 🕰), 👆 ✔️ ⚒ 💭 👈 👆 ⚙️ ⏬ 👈 👷 ☑ ⏮️ 🎂 👆 📟.
## 📌 👆 `fastapi`
🥇 👜 👆 🔜 "📌" ⏬ **FastAPI** 👆 ⚙️ 🎯 📰 ⏬ 👈 👆 💭 👷 ☑ 👆 🈸.
🖼, ➡️ 💬 👆 ⚙️ ⏬ `0.45.0` 👆 📱.
🚥 👆 ⚙️ `requirements.txt` 📁 👆 💪 ✔ ⏬ ⏮️:
```txt
fastapi==0.45.0
```
👈 🔜 ⛓ 👈 👆 🔜 ⚙️ ⚫️❔ ⏬ `0.45.0`.
⚖️ 👆 💪 📌 ⚫️ ⏮️:
```txt
fastapi>=0.45.0,<0.46.0
```
👈 🔜 ⛓ 👈 👆 🔜 ⚙️ ⏬ `0.45.0` ⚖️ 🔛, ✋️ 🌘 🌘 `0.46.0`, 🖼, ⏬ `0.45.2` 🔜 🚫.
🚥 👆 ⚙️ 🙆 🎏 🧰 🛠️ 👆 👷‍♂, 💖 🎶, Pipenv, ⚖️ 🎏, 👫 🌐 ✔️ 🌌 👈 👆 💪 ⚙️ 🔬 🎯 ⏬ 👆 📦.
## 💪 ⏬
👆 💪 👀 💪 ⏬ (✅ ✅ ⚫️❔ ⏮️ 📰) [🚀 🗒](../release-notes.md){.internal-link target=_blank}.
## 🔃 ⏬
📄 ⚛ 🛠️ 🏛, 🙆 ⏬ 🔛 `1.0.0` 💪 ⚠ 🚮 💔 🔀.
FastAPI ⏩ 🏛 👈 🙆 "🐛" ⏬ 🔀 🐛 🔧 &amp; 🚫-💔 🔀.
!!! tip
"🐛" 🏁 🔢, 🖼, `0.2.3`, 🐛 ⏬ `3`.
, 👆 🔜 💪 📌 ⏬ 💖:
```txt
fastapi>=0.45.0,<0.46.0
```
💔 🔀 &amp; 🆕 ⚒ 🚮 "🇺🇲" ⏬.
!!! tip
"🇺🇲" 🔢 🖕, 🖼, `0.2.3`, 🇺🇲 ⏬ `2`.
## ♻ FastAPI ⏬
👆 🔜 🚮 💯 👆 📱.
⏮️ **FastAPI** ⚫️ 📶 ⏩ (👏 💃), ✅ 🩺: [🔬](../tutorial/testing.md){.internal-link target=_blank}
⏮️ 👆 ✔️ 💯, ⤴️ 👆 💪 ♻ **FastAPI** ⏬ 🌖 ⏮️ 1️⃣, &amp; ⚒ 💭 👈 🌐 👆 📟 👷 ☑ 🏃 👆 💯.
🚥 🌐 👷, ⚖️ ⏮️ 👆 ⚒ 💪 🔀, &amp; 🌐 👆 💯 🚶‍♀️, ⤴️ 👆 💪 📌 👆 `fastapi` 👈 🆕 ⏮️ ⏬.
## 🔃 💃
👆 🚫🔜 🚫 📌 ⏬ `starlette`.
🎏 ⏬ **FastAPI** 🔜 ⚙️ 🎯 🆕 ⏬ 💃.
, 👆 💪 ➡️ **FastAPI** ⚙️ ☑ 💃 ⏬.
## 🔃 Pydantic
Pydantic 🔌 💯 **FastAPI** ⏮️ 🚮 👍 💯, 🆕 ⏬ Pydantic (🔛 `1.0.0`) 🕧 🔗 ⏮️ FastAPI.
👆 💪 📌 Pydantic 🙆 ⏬ 🔛 `1.0.0` 👈 👷 👆 &amp; 🔛 `2.0.0`.
🖼:
```txt
pydantic>=1.2.0,<2.0.0
```

91
docs/em/docs/external-links.md

@ -0,0 +1,91 @@
# 🔢 🔗 &amp; 📄
**FastAPI** ✔️ 👑 👪 🕧 💗.
📤 📚 🏤, 📄, 🧰, &amp; 🏗, 🔗 **FastAPI**.
📥 ❌ 📇 👫.
!!! tip
🚥 👆 ✔️ 📄, 🏗, 🧰, ⚖️ 🕳 🔗 **FastAPI** 👈 🚫 📇 📥, ✍ <a href="https://github.com/tiangolo/fastapi/edit/master/docs/en/data/external_links.yml" class="external-link" target="_blank">🚲 📨 ❎ ⚫️</a>.
## 📄
### 🇪🇸
{% if external_links %}
{% for article in external_links.articles.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇯🇵
{% if external_links %}
{% for article in external_links.articles.japanese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇻🇳
{% if external_links %}
{% for article in external_links.articles.vietnamese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇷🇺
{% if external_links %}
{% for article in external_links.articles.russian %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇩🇪
{% if external_links %}
{% for article in external_links.articles.german %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇹🇼
{% if external_links %}
{% for article in external_links.articles.taiwanese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## 📻
{% if external_links %}
{% for article in external_links.podcasts.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## 💬
{% if external_links %}
{% for article in external_links.talks.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## 🏗
⏪ 📂 🏗 ⏮️ ❔ `fastapi`:
<div class="github-topic-projects">
</div>

178
docs/em/docs/fastapi-people.md

@ -0,0 +1,178 @@
# FastAPI 👫👫
FastAPI ✔️ 🎆 👪 👈 🙋 👫👫 ⚪️➡️ 🌐 🖥.
## 👼 - 🐛
🙋 ❗ 👶
👉 👤:
{% if people %}
<div class="user-list user-list-center">
{% for user in people.maintainers %}
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a> <div class="count">❔: {{ user.answers }}</div><div class="count">🚲 📨: {{ user.prs }}</div></div>
{% endfor %}
</div>
{% endif %}
👤 👼 &amp; 🐛 **FastAPI**. 👆 💪 ✍ 🌅 🔃 👈 [ℹ FastAPI - 🤚 ℹ - 🔗 ⏮️ 📕](help-fastapi.md#connect-with-the-author){.internal-link target=_blank}.
...✋️ 📥 👤 💚 🎦 👆 👪.
---
**FastAPI** 📨 📚 🐕‍🦺 ⚪️➡️ 👪. &amp; 👤 💚 🎦 👫 💰.
👫 👫👫 👈:
* [ℹ 🎏 ⏮️ ❔ 📂](help-fastapi.md#help-others-with-questions-in-github){.internal-link target=_blank}.
* [✍ 🚲 📨](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}.
* 📄 🚲 📨, [✴️ ⚠ ✍](contributing.md#translations){.internal-link target=_blank}.
👏 👫. 👶 👶
## 🌅 🦁 👩‍💻 🏁 🗓️
👫 👩‍💻 👈 ✔️ [🤝 🎏 🏆 ⏮️ ❔ 📂](help-fastapi.md#help-others-with-questions-in-github){.internal-link target=_blank} ⏮️ 🏁 🗓️. 👶
{% if people %}
<div class="user-list user-list-center">
{% for user in people.last_month_active %}
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a> <div class="count">❔ 📨: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## 🕴
📥 **FastAPI 🕴**. 👶
👫 👩‍💻 👈 ✔️ [ℹ 🎏 🏆 ⏮️ ❔ 📂](help-fastapi.md#help-others-with-questions-in-github){.internal-link target=_blank} 🔘 *🌐 🕰*.
👫 ✔️ 🎦 🕴 🤝 📚 🎏. 👶
{% if people %}
<div class="user-list user-list-center">
{% for user in people.experts %}
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a> <div class="count">❔ 📨: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## 🔝 👨‍🔬
📥 **🔝 👨‍🔬**. 👶
👉 👩‍💻 ✔️ [✍ 🏆 🚲 📨](help-fastapi.md#create-a-pull-request){.internal-link target=_blank} 👈 ✔️ *🔗*.
👫 ✔️ 📉 ℹ 📟, 🧾, ✍, ♒️. 👶
{% if people %}
<div class="user-list user-list-center">
{% for user in people.top_contributors %}
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a> <div class="count">🚲 📨: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
📤 📚 🎏 👨‍🔬 (🌅 🌘 💯), 👆 💪 👀 👫 🌐 <a href="https://github.com/tiangolo/fastapi/graphs/contributors" class="external-link" target="_blank">FastAPI 📂 👨‍🔬 📃</a>. 👶
## 🔝 👨‍🔬
👫 👩‍💻 **🔝 👨‍🔬**. 👶 👶
### 📄 ✍
👤 🕴 💬 👩‍❤‍👨 🇪🇸 (&amp; 🚫 📶 👍 👶). , 👨‍🔬 🕐 👈 ✔️ [**🏋️ ✔ ✍**](contributing.md#translations){.internal-link target=_blank} 🧾. 🍵 👫, 📤 🚫🔜 🧾 📚 🎏 🇪🇸.
---
**🔝 👨‍🔬** 👶 👶 ✔️ 📄 🏆 🚲 📨 ⚪️➡️ 🎏, 🚚 🔆 📟, 🧾, &amp; ✴️, **✍**.
{% if people %}
<div class="user-list user-list-center">
{% for user in people.top_reviewers %}
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a> <div class="count">📄: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## 💰
👫 **💰**. 👶
👫 🔗 👇 👷 ⏮️ **FastAPI** (&amp; 🎏), ✴️ 🔘 <a href="https://github.com/sponsors/tiangolo" class="external-link" target="_blank">📂 💰</a>.
{% if sponsors %}
{% if sponsors.gold %}
### 🌟 💰
{% for sponsor in sponsors.gold -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor %}
{% endif %}
{% if sponsors.silver %}
### 🥇1st 💰
{% for sponsor in sponsors.silver -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor %}
{% endif %}
{% if sponsors.bronze %}
### 🥈2nd 💰
{% for sponsor in sponsors.bronze -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor %}
{% endif %}
{% endif %}
### 🎯 💰
{% if github_sponsors %}
{% for group in github_sponsors.sponsors %}
<div class="user-list user-list-center">
{% for user in group %}
{% if user.login not in sponsors_badge.logins %}
<div class="user"><a href="{{ user.url }}" target="_blank"><div class="avatar-wrapper"><img src="{{ user.avatarUrl }}"/></div><div class="title">@{{ user.login }}</div></a></div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
{% endif %}
## 🔃 📊 - 📡 ℹ
👑 🎯 👉 📃 🎦 🎯 👪 ℹ 🎏.
✴️ ✅ 🎯 👈 🛎 🌘 ⭐, &amp; 📚 💼 🌅 😩, 💖 🤝 🎏 ⏮️ ❔ &amp; ⚖ 🚲 📨 ⏮️ ✍.
💽 ⚖ 🔠 🗓️, 👆 💪 ✍ <a href="https://github.com/tiangolo/fastapi/blob/master/.github/actions/people/app/main.py" class="external-link" target="_blank">ℹ 📟 📥</a>.
📥 👤 🎦 💰 ⚪️➡️ 💰.
👤 🏦 ▶️️ ℹ 📊, 📄, ⚡, ♒️ (💼 🤷).

200
docs/em/docs/features.md

@ -0,0 +1,200 @@
# ⚒
## FastAPI ⚒
**FastAPI** 🤝 👆 📄:
### ⚓️ 🔛 📂 🐩
* <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>🗄</strong></a> 🛠️ 🏗, ✅ 📄 <abbr title="also known as: endpoints, routes"></abbr> <abbr title="also known as HTTP methods, as POST, GET, PUT, DELETE">🛠️</abbr>, 🔢, 💪 📨, 💂‍♂, ♒️.
* 🏧 📊 🏷 🧾 ⏮️ <a href="https://json-schema.org/" class="external-link" target="_blank"><strong>🎻 🔗</strong></a> (🗄 ⚫️ 🧢 🔛 🎻 🔗).
* 🔧 🤭 👫 🐩, ⏮️ 😔 🔬. ↩️ 👎 🧽 🔛 🔝.
* 👉 ✔ ⚙️ 🏧 **👩‍💻 📟 ⚡** 📚 🇪🇸.
### 🏧 🩺
🎓 🛠️ 🧾 &amp; 🔬 🕸 👩‍💻 🔢. 🛠️ ⚓️ 🔛 🗄, 📤 💗 🎛, 2️⃣ 🔌 🔢.
* <a href="https://github.com/swagger-api/swagger-ui" class="external-link" target="_blank"><strong>🦁 🎚</strong></a>, ⏮️ 🎓 🔬, 🤙 &amp; 💯 👆 🛠️ 🔗 ⚪️➡️ 🖥.
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-03-swagger-02.png)
* 🎛 🛠️ 🧾 ⏮️ <a href="https://github.com/Rebilly/ReDoc" class="external-link" target="_blank"><strong>📄</strong></a>.
![ReDoc](https://fastapi.tiangolo.com/img/index/index-06-redoc-02.png)
### 🏛 🐍
⚫️ 🌐 ⚓️ 🔛 🐩 **🐍 3️⃣.6️⃣ 🆎** 📄 (👏 Pydantic). 🙅‍♂ 🆕 ❕ 💡. 🐩 🏛 🐍.
🚥 👆 💪 2️⃣ ⏲ ↗️ ❔ ⚙️ 🐍 🆎 (🚥 👆 🚫 ⚙️ FastAPI), ✅ 📏 🔰: [🐍 🆎](python-types.md){.internal-link target=_blank}.
👆 ✍ 🐩 🐍 ⏮️ 🆎:
```Python
from datetime import date
from pydantic import BaseModel
# Declare a variable as a str
# and get editor support inside the function
def main(user_id: str):
return user_id
# A Pydantic model
class User(BaseModel):
id: int
name: str
joined: date
```
👈 💪 ⤴️ ⚙️ 💖:
```Python
my_user: User = User(id=3, name="John Doe", joined="2018-07-19")
second_user_data = {
"id": 4,
"name": "Mary",
"joined": "2018-11-30",
}
my_second_user: User = User(**second_user_data)
```
!!! info
`**second_user_data` ⛓:
🚶‍♀️ 🔑 &amp; 💲 `second_user_data` #️⃣ 🔗 🔑-💲 ❌, 🌓: `User(id=4, name="Mary", joined="2018-11-30")`
### 👨‍🎨 🐕‍🦺
🌐 🛠️ 🏗 ⏩ &amp; 🏋️ ⚙️, 🌐 🚫 💯 🔛 💗 👨‍🎨 ⏭ ▶️ 🛠️, 🚚 🏆 🛠️ 💡.
🏁 🐍 👩‍💻 🔬 ⚫️ 🆑 <a href="https://www.jetbrains.com/research/python-developers-survey-2017/#tools-and-features" class="external-link" target="_blank">👈 🌅 ⚙️ ⚒ "✍"</a>.
🎂 **FastAPI** 🛠️ ⚓️ 😌 👈. ✍ 👷 🌐.
👆 🔜 🛎 💪 👟 🔙 🩺.
📥 ❔ 👆 👨‍🎨 💪 ℹ 👆:
* <a href="https://code.visualstudio.com/" class="external-link" target="_blank">🎙 🎙 📟</a>:
![editor support](https://fastapi.tiangolo.com/img/vscode-completion.png)
* <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">🗒</a>:
![editor support](https://fastapi.tiangolo.com/img/pycharm-completion.png)
👆 🔜 🤚 🛠️ 📟 👆 5️⃣📆 🤔 💪 ⏭. 🖼, `price` 🔑 🔘 🎻 💪 (👈 💪 ✔️ 🐦) 👈 👟 ⚪️➡️ 📨.
🙅‍♂ 🌖 ⌨ ❌ 🔑 📛, 👟 🔙 &amp; ➡ 🖖 🩺, ⚖️ 📜 🆙 &amp; 🔽 🔎 🚥 👆 😒 ⚙️ `username` ⚖️ `user_name`.
### 📏
⚫️ ✔️ 🤔 **🔢** 🌐, ⏮️ 📦 📳 🌐. 🌐 🔢 💪 👌-🎧 ⚫️❔ 👆 💪 &amp; 🔬 🛠️ 👆 💪.
✋️ 🔢, ⚫️ 🌐 **"👷"**.
### 🔬
* 🔬 🌅 (⚖️ 🌐 ❓) 🐍 **💽 🆎**, 🔌:
* 🎻 🎚 (`dict`).
* 🎻 🎻 (`list`) ⚖ 🏬 🆎.
* 🎻 (`str`) 🏑, 🔬 🕙 &amp; 👟 📐.
* 🔢 (`int`, `float`) ⏮️ 🕙 &amp; 👟 💲, ♒️.
* 🔬 🌅 😍 🆎, 💖:
* 📛.
* 📧.
* 🆔.
* ...&amp; 🎏.
🌐 🔬 🍵 👍-🏛 &amp; 🏋️ **Pydantic**.
### 💂‍♂ &amp; 🤝
💂‍♂ &amp; 🤝 🛠️. 🍵 🙆 ⚠ ⏮️ 💽 ⚖️ 📊 🏷.
🌐 💂‍♂ ⚖ 🔬 🗄, 🔌:
* 🇺🇸🔍 🔰.
* **Oauth2️⃣** (⏮️ **🥙 🤝**). ✅ 🔰 🔛 [Oauth2️⃣ ⏮️ 🥙](tutorial/security/oauth2-jwt.md){.internal-link target=_blank}.
* 🛠️ 🔑:
* 🎚.
* 🔢 🔢.
* 🍪, ♒️.
➕ 🌐 💂‍♂ ⚒ ⚪️➡️ 💃 (🔌 **🎉 🍪**).
🌐 🏗 ♻ 🧰 &amp; 🦲 👈 ⏩ 🛠️ ⏮️ 👆 ⚙️, 📊 🏪, 🔗 &amp; ☁ 💽, ♒️.
### 🔗 💉
FastAPI 🔌 📶 ⏩ ⚙️, ✋️ 📶 🏋️ <abbr title='also known as "components", "resources", "services", "providers"'><strong>🔗 💉</strong></abbr> ⚙️.
* 🔗 💪 ✔️ 🔗, 🏗 🔗 ⚖️ **"📊" 🔗**.
* 🌐 **🔁 🍵** 🛠️.
* 🌐 🔗 💪 🚚 💽 ⚪️➡️ 📨 &amp; **↔ ➡ 🛠️** ⚛ &amp; 🏧 🧾.
* **🏧 🔬** *➡ 🛠️* 🔢 🔬 🔗.
* 🐕‍🦺 🏗 👩‍💻 🤝 ⚙️, **💽 🔗**, ♒️.
* **🙅‍♂ ⚠** ⏮️ 💽, 🕸, ♒️. ✋️ ⏩ 🛠️ ⏮️ 🌐 👫.
### ♾ "🔌-🔌"
⚖️ 🎏 🌌, 🙅‍♂ 💪 👫, 🗄 &amp; ⚙️ 📟 👆 💪.
🙆 🛠️ 🏗 🙅 ⚙️ (⏮️ 🔗) 👈 👆 💪 ✍ "🔌-" 👆 🈸 2️⃣ ⏸ 📟 ⚙️ 🎏 📊 &amp; ❕ ⚙️ 👆 *➡ 🛠️*.
### 💯
* 1️⃣0️⃣0️⃣ 💯 <abbr title="The amount of code that is automatically tested">💯 💰</abbr>.
* 1️⃣0️⃣0️⃣ 💯 <abbr title="Python type annotations, with this your editor and external tools can give you better support">🆎 ✍</abbr> 📟 🧢.
* ⚙️ 🏭 🈸.
## 💃 ⚒
**FastAPI** 🍕 🔗 ⏮️ (&amp; ⚓️ 🔛) <a href="https://www.starlette.io/" class="external-link" target="_blank"><strong>💃</strong></a>. , 🙆 🌖 💃 📟 👆 ✔️, 🔜 👷.
`FastAPI` 🤙 🎧-🎓 `Starlette`. , 🚥 👆 ⏪ 💭 ⚖️ ⚙️ 💃, 🌅 🛠️ 🔜 👷 🎏 🌌.
⏮️ **FastAPI** 👆 🤚 🌐 **💃**'Ⓜ ⚒ (FastAPI 💃 🔛 💊):
* 🤙 🎆 🎭. ⚫️ <a href="https://github.com/encode/starlette#performance" class="external-link" target="_blank">1️⃣ ⏩ 🐍 🛠️ 💪, 🔛 🇷🇪 ⏮️ **✳** &amp; **🚶**</a>.
* ** *️⃣ ** 🐕‍🦺.
* -🛠️ 🖥 📋.
* 🕴 &amp; 🤫 🎉.
* 💯 👩‍💻 🏗 🔛 🇸🇲.
* **⚜**, 🗜, 🎻 📁, 🎏 📨.
* **🎉 &amp; 🍪** 🐕‍🦺.
* 1️⃣0️⃣0️⃣ 💯 💯 💰.
* 1️⃣0️⃣0️⃣ 💯 🆎 ✍ ✍.
## Pydantic ⚒
**FastAPI** 🍕 🔗 ⏮️ (&amp; ⚓️ 🔛) <a href="https://pydantic-docs.helpmanual.io" class="external-link" target="_blank"><strong>Pydantic</strong></a>. , 🙆 🌖 Pydantic 📟 👆 ✔️, 🔜 👷.
✅ 🔢 🗃 ⚓️ 🔛 Pydantic, <abbr title="Object-Relational Mapper">🐜</abbr>Ⓜ, <abbr title="Object-Document Mapper">🏭</abbr>Ⓜ 💽.
👉 ⛓ 👈 📚 💼 👆 💪 🚶‍♀️ 🎏 🎚 👆 🤚 ⚪️➡️ 📨 **🔗 💽**, 🌐 ✔ 🔁.
🎏 ✔ 🎏 🌌 🤭, 📚 💼 👆 💪 🚶‍♀️ 🎚 👆 🤚 ⚪️➡️ 💽 **🔗 👩‍💻**.
⏮️ **FastAPI** 👆 🤚 🌐 **Pydantic**'Ⓜ ⚒ (FastAPI ⚓️ 🔛 Pydantic 🌐 💽 🚚):
* **🙅‍♂ 🔠**:
* 🙅‍♂ 🆕 🔗 🔑 ◾-🇪🇸 💡.
* 🚥 👆 💭 🐍 🆎 👆 💭 ❔ ⚙️ Pydantic.
* 🤾 🎆 ⏮️ 👆 **<abbr title="Integrated Development Environment, similar to a code editor">💾</abbr>/<abbr title="A program that checks for code errors">🧶</abbr>/🧠**:
* ↩️ Pydantic 📊 📊 👐 🎓 👆 🔬; 🚘-🛠️, 🧽, ✍ &amp; 👆 🤔 🔜 🌐 👷 ☑ ⏮️ 👆 ✔ 💽.
* **⏩**:
* <a href="https://pydantic-docs.helpmanual.io/benchmarks/" class="external-link" target="_blank">📇</a> Pydantic ⏩ 🌘 🌐 🎏 💯 🗃.
* ✔ **🏗 📊**:
* ⚙️ 🔗 Pydantic 🏷, 🐍 `typing`'Ⓜ `List` &amp; `Dict`, ♒️.
* &amp; 💳 ✔ 🏗 💽 🔗 🎯 &amp; 💪 🔬, ✅ &amp; 📄 🎻 🔗.
* 👆 💪 ✔️ 🙇 **🐦 🎻** 🎚 &amp; ✔️ 👫 🌐 ✔ &amp; ✍.
* **🏧**:
* Pydantic ✔ 🛃 📊 🆎 🔬 ⚖️ 👆 💪 ↔ 🔬 ⏮️ 👩‍🔬 🔛 🏷 🎀 ⏮️ 💳 👨‍🎨.
* 1️⃣0️⃣0️⃣ 💯 💯 💰.

265
docs/em/docs/help-fastapi.md

@ -0,0 +1,265 @@
# ℹ FastAPI - 🤚 ℹ
👆 💖 **FastAPI**
🔜 👆 💖 ℹ FastAPI, 🎏 👩‍💻, &amp; 📕 ❓
⚖️ 🔜 👆 💖 🤚 ℹ ⏮️ **FastAPI**
📤 📶 🙅 🌌 ℹ (📚 🔌 1️⃣ ⚖️ 2️⃣ 🖊).
&amp; 📤 📚 🌌 🤚 ℹ 💁‍♂️.
## 👱📔 📰
👆 💪 👱📔 (🐌) [**FastAPI &amp; 👨‍👧‍👦** 📰](/newsletter/){.internal-link target=_blank} 🚧 ℹ 🔃:
* 📰 🔃 FastAPI &amp; 👨‍👧‍👦 👶
* 🦮 👶
* ⚒ 👶
* 💔 🔀 👶
* 💁‍♂ &amp; 🎱 👶
## ⏩ FastAPI 🔛 👱📔
<a href="https://twitter.com/fastapi" class="external-link" target="_blank">⏩ 🐶 Fastapi 🔛 **👱📔**</a> 🤚 📰 📰 🔃 **FastAPI**. 👶
## ✴ **FastAPI** 📂
👆 💪 "✴" FastAPI 📂 (🖊 ✴ 🔼 🔝 ▶️️): <a href="https://github.com/tiangolo/fastapi" class="external-link" target="_blank">https://github.com/tiangolo/fastapi</a>. 👶 👶
❎ ✴, 🎏 👩‍💻 🔜 💪 🔎 ⚫️ 🌅 💪 &amp; 👀 👈 ⚫️ ✔️ ⏪ ⚠ 🎏.
## ⌚ 📂 🗃 🚀
👆 💪 "⌚" FastAPI 📂 (🖊 "⌚" 🔼 🔝 ▶️️): <a href="https://github.com/tiangolo/fastapi" class="external-link" target="_blank">https://github.com/tiangolo/fastapi</a>. 👶
📤 👆 💪 🖊 "🚀 🕴".
🔨 ⚫️, 👆 🔜 📨 📨 (👆 📧) 🕐❔ 📤 🆕 🚀 (🆕 ⏬) **FastAPI** ⏮️ 🐛 🔧 &amp; 🆕 ⚒.
## 🔗 ⏮️ 📕
👆 💪 🔗 ⏮️ <a href="https://tiangolo.com" class="external-link" target="_blank">👤 (🇹🇦 🇩🇬 / `tiangolo`)</a>, 📕.
👆 💪:
* <a href="https://github.com/tiangolo" class="external-link" target="_blank">⏩ 👤 🔛 **📂**</a>.
* 👀 🎏 📂 ℹ 🏗 👤 ✔️ ✍ 👈 💪 ℹ 👆.
* ⏩ 👤 👀 🕐❔ 👤 ✍ 🆕 📂 ℹ 🏗.
* <a href="https://twitter.com/tiangolo" class="external-link" target="_blank">⏩ 👤 🔛 **👱📔**</a> ⚖️ <a href="https://fosstodon.org/@tiangolo" class="external-link" target="_blank"></a>.
* 💬 👤 ❔ 👆 ⚙️ FastAPI (👤 💌 👂 👈).
* 👂 🕐❔ 👤 ⚒ 🎉 ⚖️ 🚀 🆕 🧰.
* 👆 💪 <a href="https://twitter.com/fastapi" class="external-link" target="_blank">⏩ 🐶 Fastapi 🔛 👱📔</a> (🎏 🏧).
* <a href="https://www.linkedin.com/in/tiangolo/" class="external-link" target="_blank">🔗 ⏮️ 👤 🔛 **👱📔**</a>.
* 👂 🕐❔ 👤 ⚒ 🎉 ⚖️ 🚀 🆕 🧰 (👐 👤 ⚙️ 👱📔 🌖 🛎 🤷 ♂).
* ✍ ⚫️❔ 👤 ✍ (⚖️ ⏩ 👤) 🔛 <a href="https://dev.to/tiangolo" class="external-link" target="_blank">**🇸🇲.**</a> ⚖️ <a href="https://medium.com/@tiangolo" class="external-link" target="_blank">**🔉**</a>.
* ✍ 🎏 💭, 📄, &amp; ✍ 🔃 🧰 👤 ✔️ ✍.
* ⏩ 👤 ✍ 🕐❔ 👤 ✍ 🕳 🆕.
## 👱📔 🔃 **FastAPI**
<a href="https://twitter.com/compose/tweet?text=I'm loving @fastapi because... https://github.com/tiangolo/fastapi" class="external-link" target="_blank">👱📔 🔃 **FastAPI**</a> &amp; ➡️ 👤 &amp; 🎏 💭 ⚫️❔ 👆 💖 ⚫️. 👶
👤 💌 👂 🔃 ❔ **FastAPI** 💆‍♂ ⚙️, ⚫️❔ 👆 ✔️ 💖 ⚫️, ❔ 🏗/🏢 👆 ⚙️ ⚫️, ♒️.
## 🗳 FastAPI
* <a href="https://www.slant.co/options/34241/~fastapi-review" class="external-link" target="_blank">🗳 **FastAPI** 📐</a>.
* <a href="https://alternativeto.net/software/fastapi/" class="external-link" target="_blank">🗳 **FastAPI** 📱</a>.
* <a href="https://stackshare.io/pypi-fastapi" class="external-link" target="_blank">💬 👆 ⚙️ **FastAPI** 🔛 ℹ</a>.
## ℹ 🎏 ⏮️ ❔ 📂
👆 💪 🔄 &amp; ℹ 🎏 ⏮️ 👫 ❔:
* <a href="https://github.com/tiangolo/fastapi/discussions/categories/questions?discussions_q=category%3AQuestions+is%3Aunanswered" class="external-link" target="_blank">📂 💬</a>
* <a href="https://github.com/tiangolo/fastapi/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Aquestion+-label%3Aanswered+" class="external-link" target="_blank">📂 ❔</a>
📚 💼 👆 5️⃣📆 ⏪ 💭 ❔ 📚 ❔. 👶
🚥 👆 🤝 📚 👫👫 ⏮️ 👫 ❔, 👆 🔜 ▶️️ 🛂 [FastAPI 🕴](fastapi-people.md#experts){.internal-link target=_blank}. 👶
💭, 🏆 ⚠ ☝: 🔄 😇. 👫👫 👟 ⏮️ 👫 😩 &amp; 📚 💼 🚫 💭 🏆 🌌, ✋️ 🔄 🏆 👆 💪 😇. 👶
💭 **FastAPI** 👪 😇 &amp; 👍. 🎏 🕰, 🚫 🚫 🎭 ⚖️ 😛 🎭 ⤵ 🎏. 👥 ✔️ ✊ 💅 🔠 🎏.
---
📥 ❔ ℹ 🎏 ⏮️ ❔ (💬 ⚖️ ❔):
### 🤔 ❔
* ✅ 🚥 👆 💪 🤔 ⚫️❔ **🎯** &amp; ⚙️ 💼 👨‍💼 💬.
* ⤴️ ✅ 🚥 ❔ (⭕ 👪 ❔) **🆑**.
* 📚 💼 ❔ 💭 🔃 👽 ⚗ ⚪️➡️ 👩‍💻, ✋️ 📤 💪 **👍** 1️⃣. 🚥 👆 💪 🤔 ⚠ &amp; ⚙️ 💼 👍, 👆 💪 💪 🤔 👍 **🎛 ⚗**.
* 🚥 👆 💪 🚫 🤔 ❔, 💭 🌖 **ℹ**.
### 🔬 ⚠
🌅 💼 &amp; 🏆 ❔ 📤 🕳 🔗 👨‍💼 **⏮️ 📟**.
📚 💼 👫 🔜 🕴 📁 🧬 📟, ✋️ 👈 🚫 🥃 **🔬 ⚠**.
* 👆 💪 💭 👫 🚚 <a href="https://stackoverflow.com/help/minimal-reproducible-example" class="external-link" target="_blank">⭐, 🔬, 🖼</a>, 👈 👆 💪 **📁-📋** &amp; 🏃 🌐 👀 🎏 ❌ ⚖️ 🎭 👫 👀, ⚖️ 🤔 👫 ⚙️ 💼 👍.
* 🚥 👆 😟 💁‍♂️ 👍, 👆 💪 🔄 **✍ 🖼** 💖 👈 👆, 🧢 🔛 📛 ⚠. ✔️ 🤯 👈 👉 💪 ✊ 📚 🕰 &amp; ⚫️ 💪 👻 💭 👫 ✍ ⚠ 🥇.
### 🤔 ⚗
* ⏮️ 💆‍♂ 💪 🤔 ❔, 👆 💪 🤝 👫 💪 **❔**.
* 📚 💼, ⚫️ 👍 🤔 👫 **📈 ⚠ ⚖️ ⚙️ 💼**, ↩️ 📤 5️⃣📆 👍 🌌 ❎ ⚫️ 🌘 ⚫️❔ 👫 🔄.
### 💭 🔐
🚥 👫 📨, 📤 ↕ 🤞 👆 🔜 ✔️ ❎ 👫 ⚠, ㊗, **👆 💂**❗ 🦸
* 🔜, 🚥 👈 ❎ 👫 ⚠, 👆 💪 💭 👫:
* 📂 💬: ™ 🏤 **❔**.
* 📂 ❔: **🔐** ❔**.
## ⌚ 📂 🗃
👆 💪 "⌚" FastAPI 📂 (🖊 "⌚" 🔼 🔝 ▶️️): <a href="https://github.com/tiangolo/fastapi" class="external-link" target="_blank">https://github.com/tiangolo/fastapi</a>. 👶
🚥 👆 🖊 "👀" ↩️ "🚀 🕴" 👆 🔜 📨 📨 🕐❔ 👱 ✍ 🆕 ❔ ⚖️ ❔. 👆 💪 ✔ 👈 👆 🕴 💚 🚨 🔃 🆕 ❔, ⚖️ 💬, ⚖️ 🎸, ♒️.
⤴️ 👆 💪 🔄 &amp; ℹ 👫 ❎ 👈 ❔.
## 💭 ❔
👆 💪 <a href="https://github.com/tiangolo/fastapi/discussions/new?category=questions" class="external-link" target="_blank">✍ 🆕 ❔</a> 📂 🗃, 🖼:
* 💭 **❔** ⚖️ 💭 🔃 **⚠**.
* 🤔 🆕 **⚒**.
**🗒**: 🚥 👆 ⚫️, ⤴️ 👤 🔜 💭 👆 ℹ 🎏. 👶
## 📄 🚲 📨
👆 💪 ℹ 👤 📄 🚲 📨 ⚪️➡️ 🎏.
🔄, 🙏 🔄 👆 🏆 😇. 👶
---
📥 ⚫️❔ ✔️ 🤯 &amp; ❔ 📄 🚲 📨:
### 🤔 ⚠
* 🥇, ⚒ 💭 👆 **🤔 ⚠** 👈 🚲 📨 🔄 ❎. ⚫️ 💪 ✔️ 📏 💬 📂 💬 ⚖️ ❔.
* 📤 👍 🤞 👈 🚲 📨 🚫 🤙 💪 ↩️ ⚠ 💪 ❎ **🎏 🌌**. ⤴️ 👆 💪 🤔 ⚖️ 💭 🔃 👈.
### 🚫 😟 🔃 👗
* 🚫 😟 💁‍♂️ 🌅 🔃 👜 💖 💕 📧 👗, 👤 🔜 🥬 &amp; 🔗 🛃 💕 ❎.
* 🚫 😟 🔃 👗 🚫, 📤 ⏪ 🏧 🧰 ✅ 👈.
&amp; 🚥 📤 🙆 🎏 👗 ⚖️ ⚖ 💪, 👤 🔜 💭 🔗 👈, ⚖️ 👤 🔜 🚮 💕 🔛 🔝 ⏮️ 💪 🔀.
### ✅ 📟
* ✅ &amp; ✍ 📟, 👀 🚥 ⚫️ ⚒ 🔑, **🏃 ⚫️ 🌐** &amp; 👀 🚥 ⚫️ 🤙 ❎ ⚠.
* ⤴️ **🏤** 💬 👈 👆 👈, 👈 ❔ 👤 🔜 💭 👆 🤙 ✅ ⚫️.
!!! info
👐, 👤 💪 🚫 🎯 💙 🎸 👈 ✔️ 📚 ✔.
📚 🕰 ⚫️ ✔️ 🔨 👈 📤 🎸 ⏮️ 3️⃣, 5️⃣ ⚖️ 🌅 ✔, 🎲 ↩️ 📛 😌, ✋️ 🕐❔ 👤 ✅ 🎸, 👫 🤙 💔, ✔️ 🐛, ⚖️ 🚫 ❎ ⚠ 👫 🛄 ❎. 👶
, ⚫️ 🤙 ⚠ 👈 👆 🤙 ✍ &amp; 🏃 📟, &amp; ➡️ 👤 💭 🏤 👈 👆. 👶
* 🚥 🇵🇷 💪 📉 🌌, 👆 💪 💭 👈, ✋️ 📤 🙅‍♂ 💪 💁‍♂️ 😟, 📤 5️⃣📆 📚 🤔 ☝ 🎑 (&amp; 👤 🔜 ✔️ 👇 👍 👍 👶), ⚫️ 👻 🚥 👆 💪 🎯 🔛 ⚛ 👜.
### 💯
* ℹ 👤 ✅ 👈 🇵🇷 ✔️ **💯**.
* ✅ 👈 💯 **❌** ⏭ 🇵🇷. 👶
* ⤴️ ✅ 👈 💯 **🚶‍♀️** ⏮️ 🇵🇷. 👶
* 📚 🎸 🚫 ✔️ 💯, 👆 💪 **🎗** 👫 🚮 💯, ⚖️ 👆 💪 **🤔** 💯 👆. 👈 1️⃣ 👜 👈 🍴 🌅 🕰 &amp; 👆 💪 ℹ 📚 ⏮️ 👈.
* ⤴️ 🏤 ⚫️❔ 👆 🔄, 👈 🌌 👤 🔜 💭 👈 👆 ✅ ⚫️. 👶
## ✍ 🚲 📨
👆 💪 [📉](contributing.md){.internal-link target=_blank} ℹ 📟 ⏮️ 🚲 📨, 🖼:
* 🔧 🤭 👆 🔎 🔛 🧾.
* 💰 📄, 📹, ⚖️ 📻 👆 ✍ ⚖️ 🔎 🔃 FastAPI <a href="https://github.com/tiangolo/fastapi/edit/master/docs/en/data/external_links.yml" class="external-link" target="_blank">✍ 👉 📁</a>.
* ⚒ 💭 👆 🚮 👆 🔗 ▶️ 🔗 📄.
* ℹ [💬 🧾](contributing.md#translations){.internal-link target=_blank} 👆 🇪🇸.
* 👆 💪 ℹ 📄 ✍ ✍ 🎏.
* 🛠️ 🆕 🧾 📄.
* 🔧 ♻ ❔/🐛.
* ⚒ 💭 🚮 💯.
* 🚮 🆕 ⚒.
* ⚒ 💭 🚮 💯.
* ⚒ 💭 🚮 🧾 🚥 ⚫️ 🔗.
## ℹ 🚧 FastAPI
ℹ 👤 🚧 **FastAPI**❗ 👶
📤 📚 👷, &amp; 🏆 ⚫️, **👆** 💪 ⚫️.
👑 📋 👈 👆 💪 ▶️️ 🔜:
* [ℹ 🎏 ⏮️ ❔ 📂](#help-others-with-questions-in-github){.internal-link target=_blank} (👀 📄 🔛).
* [📄 🚲 📨](#review-pull-requests){.internal-link target=_blank} (👀 📄 🔛).
👈 2️⃣ 📋 ⚫️❔ **🍴 🕰 🏆**. 👈 👑 👷 🏆 FastAPI.
🚥 👆 💪 ℹ 👤 ⏮️ 👈, **👆 🤝 👤 🚧 FastAPI** &amp; ⚒ 💭 ⚫️ 🚧 **🛠️ ⏩ &amp; 👻**. 👶
## 🛑 💬
🛑 👶 <a href="https://discord.gg/VQjSZaeJmf" class="external-link" target="_blank">😧 💬 💽</a> 👶 &amp; 🤙 👅 ⏮️ 🎏 FastAPI 👪.
!!! tip
❔, 💭 👫 <a href="https://github.com/tiangolo/fastapi/discussions/new?category=questions" class="external-link" target="_blank">📂 💬</a>, 📤 🌅 👍 🤞 👆 🔜 📨 ℹ [FastAPI 🕴](fastapi-people.md#experts){.internal-link target=_blank}.
⚙️ 💬 🕴 🎏 🏢 💬.
📤 ⏮️ <a href="https://gitter.im/tiangolo/fastapi" class="external-link" target="_blank">🥊 💬</a>, ✋️ ⚫️ 🚫 ✔️ 📻 &amp; 🏧 ⚒, 💬 🌖 ⚠, 😧 🔜 👍 ⚙️.
### 🚫 ⚙️ 💬 ❔
✔️ 🤯 👈 💬 ✔ 🌅 "🆓 💬", ⚫️ ⏩ 💭 ❔ 👈 💁‍♂️ 🏢 &amp; 🌅 ⚠ ❔,, 👆 💪 🚫 📨 ❔.
📂, 📄 🔜 🦮 👆 ✍ ▶️️ ❔ 👈 👆 💪 🌖 💪 🤚 👍 ❔, ⚖️ ❎ ⚠ 👆 ⏭ 💬. &amp; 📂 👤 💪 ⚒ 💭 👤 🕧 ❔ 🌐, 🚥 ⚫️ ✊ 🕰. 👤 💪 🚫 🤙 👈 ⏮️ 💬 ⚙️. 👶
💬 💬 ⚙️ 🚫 💪 📇 📂, ❔ &amp; ❔ 5️⃣📆 🤚 💸 💬. &amp; 🕴 🕐 📂 💯 ▶️️ [FastAPI 🕴](fastapi-people.md#experts){.internal-link target=_blank}, 👆 🔜 🌅 🎲 📨 🌅 🙋 📂.
🔛 🎏 🚄, 📤 💯 👩‍💻 💬 ⚙️, 📤 ↕ 🤞 👆 🔜 🔎 👱 💬 📤, 🌖 🌐 🕰. 👶
## 💰 📕
👆 💪 💰 🐕‍🦺 📕 (👤) 🔘 <a href="https://github.com/sponsors/tiangolo" class="external-link" target="_blank">📂 💰</a>.
📤 👆 💪 🛍 👤 ☕ 👶 👶 💬 👏. 👶
&amp; 👆 💪 ▶️️ 🥇1st ⚖️ 🌟 💰 FastAPI. 👶 👶
## 💰 🧰 👈 🏋️ FastAPI
👆 ✔️ 👀 🧾, FastAPI 🧍 🔛 ⌚ 🐘, 💃 &amp; Pydantic.
👆 💪 💰:
* <a href="https://github.com/sponsors/samuelcolvin" class="external-link" target="_blank">✡ 🍏 (Pydantic)</a>
* <a href="https://github.com/sponsors/encode" class="external-link" target="_blank">🗜 (💃, Uvicorn)</a>
---
👏 ❗ 👶

79
docs/em/docs/history-design-future.md

@ -0,0 +1,79 @@
# 📖, 🔧 &amp; 🔮
🕰 🏁, <a href="https://github.com/tiangolo/fastapi/issues/3#issuecomment-454956920" class="external-link" target="_blank"> **FastAPI** 👩‍💻 💭</a>:
&gt; ⚫️❔ 📖 👉 🏗 ❓ ⚫️ 😑 ✔️ 👟 ⚪️➡️ 🕳 👌 👩‍❤‍👨 🗓️ [...]
📥 🐥 🍖 👈 📖.
## 🎛
👤 ✔️ 🏗 🔗 ⏮️ 🏗 📄 📚 1️⃣2️⃣🗓️ (🎰 🏫, 📎 ⚙️, 🔁 👨‍🏭, ☁ 💽, ♒️), ↘️ 📚 🏉 👩‍💻.
🍕 👈, 👤 💪 🔬, 💯 &amp; ⚙️ 📚 🎛.
📖 **FastAPI** 👑 🍕 📖 🚮 ⏪.
🙆‍♀ 📄 [🎛](alternatives.md){.internal-link target=_blank}:
<blockquote markdown="1">
**FastAPI** 🚫🔜 🔀 🚥 🚫 ⏮️ 👷 🎏.
📤 ✔️ 📚 🧰 ✍ ⏭ 👈 ✔️ ℹ 😮 🚮 🏗.
👤 ✔️ ❎ 🏗 🆕 🛠️ 📚 1️⃣2️⃣🗓️. 🥇 👤 🔄 ❎ 🌐 ⚒ 📔 **FastAPI** ⚙️ 📚 🎏 🛠️, 🔌-🔌, &amp; 🧰.
✋️ ☝, 📤 🙅‍♂ 🎏 🎛 🌘 🏗 🕳 👈 🚚 🌐 👫 ⚒, ✊ 🏆 💭 ⚪️➡️ ⏮️ 🧰, &amp; 🌀 👫 🏆 🌌 💪, ⚙️ 🇪🇸 ⚒ 👈 ➖🚫 💪 ⏭ (🐍 3️⃣.6️⃣ ➕ 🆎 🔑).
</blockquote>
## 🔬
⚙️ 🌐 ⏮️ 🎛 👤 ✔️ 🤞 💡 ⚪️➡️ 🌐 👫, ✊ 💭, &amp; 🌀 👫 🏆 🌌 👤 💪 🔎 👤 &amp; 🏉 👩‍💻 👤 ✔️ 👷 ⏮️.
🖼, ⚫️ 🆑 👈 🎲 ⚫️ 🔜 ⚓️ 🔛 🐩 🐍 🆎 🔑.
, 🏆 🎯 ⚙️ ⏪ ♻ 🐩.
, ⏭ ▶️ 📟 **FastAPI**, 👤 💸 📚 🗓️ 🎓 🔌 🗄, 🎻 🔗, Oauth2️⃣, ♒️. 🎯 👫 💛, 🔀, &amp; 🔺.
## 🔧
⤴️ 👤 💸 🕰 🔧 👩‍💻 "🛠️" 👤 💚 ✔️ 👩‍💻 (👩‍💻 ⚙️ FastAPI).
👤 💯 📚 💭 🏆 🌟 🐍 👨‍🎨: 🗒, 🆚 📟, 🎠 🧢 👨‍🎨.
🏁 <a href="https://www.jetbrains.com/research/python-developers-survey-2018/#development-tools" class="external-link" target="_blank">🐍 👩‍💻 🔬</a>, 👈 📔 🔃 8️⃣0️⃣ 💯 👩‍💻.
⚫️ ⛓ 👈 **FastAPI** 🎯 💯 ⏮️ 👨‍🎨 ⚙️ 8️⃣0️⃣ 💯 🐍 👩‍💻. &amp; 🏆 🎏 👨‍🎨 😑 👷 ➡, 🌐 🚮 💰 🔜 👷 🌖 🌐 👨‍🎨.
👈 🌌 👤 💪 🔎 🏆 🌌 📉 📟 ❎ 🌅 💪, ✔️ 🛠️ 🌐, 🆎 &amp; ❌ ✅, ♒️.
🌐 🌌 👈 🚚 🏆 🛠️ 💡 🌐 👩‍💻.
## 📄
⏮️ 🔬 📚 🎛, 👤 💭 👈 👤 🔜 ⚙️ <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">**Pydantic**</a> 🚮 📈.
⤴️ 👤 📉 ⚫️, ⚒ ⚫️ 🍕 🛠️ ⏮️ 🎻 🔗, 🐕‍🦺 🎏 🌌 🔬 ⚛ 📄, &amp; 📉 👨‍🎨 🐕‍🦺 (🆎 ✅, ✍) ⚓️ 🔛 💯 📚 👨‍🎨.
⏮️ 🛠️, 👤 📉 <a href="https://www.starlette.io/" class="external-link" target="_blank">**💃**</a>, 🎏 🔑 📄.
## 🛠️
🕰 👤 ▶️ 🏗 **FastAPI** ⚫️, 🏆 🍖 ⏪ 🥉, 🔧 🔬, 📄 &amp; 🧰 🔜, &amp; 💡 🔃 🐩 &amp; 🔧 🆑 &amp; 🍋.
## 🔮
👉 ☝, ⚫️ ⏪ 🆑 👈 **FastAPI** ⏮️ 🚮 💭 ➖ ⚠ 📚 👫👫.
⚫️ 💆‍♂ 👐 🤭 ⏮️ 🎛 ♣ 📚 ⚙️ 💼 👍.
📚 👩‍💻 &amp; 🏉 ⏪ 🪀 🔛 **FastAPI** 👫 🏗 (🔌 👤 &amp; 👇 🏉).
✋️, 📤 📚 📈 &amp; ⚒ 👟.
**FastAPI** ✔️ 👑 🔮 ⤴️.
&amp; [👆 ℹ](help-fastapi.md){.internal-link target=_blank} 📉 👍.

469
docs/em/docs/index.md

@ -0,0 +1,469 @@
<p align="center">
<a href="https://fastapi.tiangolo.com"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" alt="FastAPI"></a>
</p>
<p align="center">
<em>FastAPI 🛠️, ↕ 🎭, ⏩ 💡, ⏩ 📟, 🔜 🏭</em>
</p>
<p align="center">
<a href="https://github.com/tiangolo/fastapi/actions?query=workflow%3ATest+event%3Apush+branch%3Amaster" target="_blank">
<img src="https://github.com/tiangolo/fastapi/workflows/Test/badge.svg?event=push&branch=master" alt="Test">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/fastapi" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/fastapi.svg" alt="Coverage">
</a>
<a href="https://pypi.org/project/fastapi" target="_blank">
<img src="https://img.shields.io/pypi/v/fastapi?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypi.org/project/fastapi" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/fastapi.svg?color=%2334D058" alt="Supported Python versions">
</a>
</p>
---
**🧾**: <a href="https://fastapi.tiangolo.com" target="_blank">https://fastapi.tiangolo.com</a>
**ℹ 📟**: <a href="https://github.com/tiangolo/fastapi" target="_blank">https://github.com/tiangolo/fastapi</a>
---
FastAPI 🏛, ⏩ (↕-🎭), 🕸 🛠️ 🏗 🛠️ ⏮️ 🐍 3️⃣.7️⃣ ➕ ⚓️ 🔛 🐩 🐍 🆎 🔑.
🔑 ⚒:
* **⏩**: 📶 ↕ 🎭, 🔛 🇷🇪 ⏮️ **✳** &amp; **🚶** (👏 💃 &amp; Pydantic). [1️⃣ ⏩ 🐍 🛠️ 💪](#performance).
* **⏩ 📟**: 📈 🚅 🛠️ ⚒ 🔃 2️⃣0️⃣0️⃣ 💯 3️⃣0️⃣0️⃣ 💯. *
* **👩‍❤‍👨 🐛**: 📉 🔃 4️⃣0️⃣ 💯 🗿 (👩‍💻) 📉 ❌. *
* **🏋️**: 👑 👨‍🎨 🐕‍🦺. <abbr title="also known as auto-complete, autocompletion, IntelliSense">🛠️</abbr> 🌐. 🌘 🕰 🛠️.
* **⏩**: 🔧 ⏩ ⚙️ &amp; 💡. 🌘 🕰 👂 🩺.
* **📏**: 📉 📟 ❎. 💗 ⚒ ⚪️➡️ 🔠 🔢 📄. 👩‍❤‍👨 🐛.
* **🏋️**: 🤚 🏭-🔜 📟. ⏮️ 🏧 🎓 🧾.
* **🐩-⚓️**: ⚓️ 🔛 (&amp; 🍕 🔗 ⏮️) 📂 🐩 🔗: <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank">🗄</a> (⏪ 💭 🦁) &amp; <a href="https://json-schema.org/" class="external-link" target="_blank">🎻 🔗</a>.
<small>* ⚖ ⚓️ 🔛 💯 🔛 🔗 🛠️ 🏉, 🏗 🏭 🈸.</small>
## 💰
<!-- sponsors -->
{% if sponsors %}
{% for sponsor in sponsors.gold -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor -%}
{%- for sponsor in sponsors.silver -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor %}
{% endif %}
<!-- /sponsors -->
<a href="https://fastapi.tiangolo.com/fastapi-people/#sponsors" class="external-link" target="_blank">🎏 💰</a>
## 🤔
"_[...] 👤 ⚙️ **FastAPI** 📚 👫 📆. [...] 👤 🤙 📆 ⚙️ ⚫️ 🌐 👇 🏉 **⚗ 🐕‍🦺 🤸‍♂**. 👫 💆‍♂ 🛠️ 🔘 🐚 **🖥** 🏬 &amp; **📠** 🏬._"
<div style="text-align: right; margin-right: 10%;">🧿 🇵🇰 - <strong>🤸‍♂</strong> <a href="https://github.com/tiangolo/fastapi/pull/26" target="_blank"><small>(🇦🇪)</small></a></div>
---
"_👥 🛠️ **FastAPI** 🗃 🤖 **🎂** 💽 👈 💪 🔢 🚚 **🔮**. [👨📛]_"
<div style="text-align: right; margin-right: 10%;">🇮🇹 🇸🇻, 👨📛 👨📛, &amp; 🇱🇰 🕉 🕉 - <strong>🙃</strong> <a href="https://eng.uber.com/ludwig-v0-2/" target="_blank"><small>(🇦🇪)</small></a></div>
---
"_**📺** 🙏 📣 📂-ℹ 🚀 👆 **⚔ 🧾** 🎶 🛠️: **📨**❗ [🏗 ⏮️ **FastAPI**]_"
<div style="text-align: right; margin-right: 10%;">✡ 🍏, 👖 🇪🇸, 🌲 🍏 - <strong>📺</strong> <a href="https://netflixtechblog.com/introducing-dispatch-da4b8a2a8072" target="_blank"><small>(🇦🇪)</small></a></div>
---
"_👤 🤭 🌕 😄 🔃 **FastAPI**. ⚫️ 🎊 ❗_"
<div style="text-align: right; margin-right: 10%;">✡ 🇭🇰 - <strong><a href="https://pythonbytes.fm/episodes/show/123/time-to-right-the-py-wrongs?time_in_sec=855" target="_blank">🐍 🔢</a> 📻 🦠</strong> <a href="https://twitter.com/brianokken/status/1112220079972728832" target="_blank"><small>(🇦🇪)</small></a></div>
---
"_🤙, ⚫️❔ 👆 ✔️ 🏗 👀 💎 💠 &amp; 🇵🇱. 📚 🌌, ⚫️ ⚫️❔ 👤 💚 **🤗** - ⚫️ 🤙 😍 👀 👱 🏗 👈._"
<div style="text-align: right; margin-right: 10%;">✡ 🗄 - <strong><a href="https://www.hug.rest/" target="_blank">🤗</a> 👼</strong> <a href="https://news.ycombinator.com/item?id=19455465" target="_blank"><small>(🇦🇪)</small></a></div>
---
"_🚥 👆 👀 💡 1️⃣ **🏛 🛠️** 🏗 🎂 🔗, ✅ 👅 **FastAPI** [...] ⚫️ ⏩, ⏩ ⚙️ &amp; ⏩ 💡 [...]_"
"_👥 ✔️ 🎛 🤭 **FastAPI** 👆 **🔗** [...] 👤 💭 👆 🔜 💖 ⚫️ [...]_"
<div style="text-align: right; margin-right: 10%;">🇱🇨 🇸🇲 - ✡ Honnibal - <strong><a href="https://explosion.ai" target="_blank">💥 👲</a> 🕴 - <a href="https://spacy.io" target="_blank">🌈</a> 👼</strong> <a href="https://twitter.com/_inesmontani/status/1144173225322143744" target="_blank"><small>(🇦🇪)</small></a> - <a href="https://twitter.com/honnibal/status/1144031421859655680" target="_blank"><small>(🇦🇪)</small></a></div>
---
"_🚥 🙆 👀 🏗 🏭 🐍 🛠️, 👤 🔜 🏆 👍 **FastAPI**. ⚫️ **💎 🏗**, **🙅 ⚙️** &amp; **🏆 🛠️**, ⚫️ ✔️ ▶️️ **🔑 🦲** 👆 🛠️ 🥇 🛠️ 🎛 &amp; 🚘 📚 🏧 &amp; 🐕‍🦺 ✅ 👆 🕹 🔫 👨‍💻._"
<div style="text-align: right; margin-right: 10%;">🇹🇦 🍰 - <strong>📻</strong> <a href="https://www.linkedin.com/posts/deonpillsbury_cisco-cx-python-activity-6963242628536487936-trAp/" target="_blank"><small>(🇦🇪)</small></a></div>
---
## **🏎**, FastAPI 🇳🇨
<a href="https://typer.tiangolo.com" target="_blank"><img src="https://typer.tiangolo.com/img/logo-margin/logo-margin-vector.svg" style="width: 20%;"></a>
🚥 👆 🏗 <abbr title="Command Line Interface"></abbr> 📱 ⚙️ 📶 ↩️ 🕸 🛠️, ✅ 👅 <a href="https://typer.tiangolo.com/" class="external-link" target="_blank">**🏎**</a>.
**🏎** FastAPI 🐥 👪. &amp; ⚫️ 🎯 **FastAPI 🇳🇨**. 👶 👶 👶
## 📄
🐍 3️⃣.7️⃣ ➕
FastAPI 🧍 🔛 ⌚ 🐘:
* <a href="https://www.starlette.io/" class="external-link" target="_blank">💃</a> 🕸 🍕.
* <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> 📊 🍕.
## 👷‍♂
<div class="termy">
```console
$ pip install fastapi
---> 100%
```
</div>
👆 🔜 💪 🔫 💽, 🏭 ✅ <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a> ⚖️ <a href="https://github.com/pgjones/hypercorn" class="external-link" target="_blank">Hypercorn</a>.
<div class="termy">
```console
$ pip install "uvicorn[standard]"
---> 100%
```
</div>
## 🖼
### ✍ ⚫️
* ✍ 📁 `main.py` ⏮️:
```Python
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
```
<details markdown="1">
<summary>⚖️ ⚙️ <code>async def</code>...</summary>
🚥 👆 📟 ⚙️ `async` / `await`, ⚙️ `async def`:
```Python hl_lines="9 14"
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
async def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
```
**🗒**:
🚥 👆 🚫 💭, ✅ _"🏃 ❓" _ 📄 🔃 <a href="https://fastapi.tiangolo.com/async/#in-a-hurry" target="_blank">`async` &amp; `await` 🩺</a>.
</details>
### 🏃 ⚫️
🏃 💽 ⏮️:
<div class="termy">
```console
$ uvicorn main:app --reload
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [28720]
INFO: Started server process [28722]
INFO: Waiting for application startup.
INFO: Application startup complete.
```
</div>
<details markdown="1">
<summary>🔃 📋 <code>uvicorn main:app --reload</code>...</summary>
📋 `uvicorn main:app` 🔗:
* `main`: 📁 `main.py` (🐍 "🕹").
* `app`: 🎚 ✍ 🔘 `main.py` ⏮️ ⏸ `app = FastAPI()`.
* `--reload`: ⚒ 💽 ⏏ ⏮️ 📟 🔀. 🕴 👉 🛠️.
</details>
### ✅ ⚫️
📂 👆 🖥 <a href="http://127.0.0.1:8000/items/5?q=somequery" class="external-link" target="_blank">http://127.0.0.1:8000/items/5?q=somequery</a>.
👆 🔜 👀 🎻 📨:
```JSON
{"item_id": 5, "q": "somequery"}
```
👆 ⏪ ✍ 🛠️ 👈:
* 📨 🇺🇸🔍 📨 _➡_ `/` &amp; `/items/{item_id}`.
* 👯‍♂️ _➡_`GET` <em>🛠️</em> (💭 🇺🇸🔍 _👩‍🔬_).
* _➡_ `/items/{item_id}` ✔️ _➡ 🔢_ `item_id` 👈 🔜 `int`.
* _➡_ `/items/{item_id}` ✔️ 📦 `str` _🔢 = `q`.
### 🎓 🛠️ 🩺
🔜 🚶 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
👆 🔜 👀 🏧 🎓 🛠️ 🧾 (🚚 <a href="https://github.com/swagger-api/swagger-ui" class="external-link" target="_blank">🦁 🎚</a>):
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-01-swagger-ui-simple.png)
### 🎛 🛠️ 🩺
&amp; 🔜, 🚶 <a href="http://127.0.0.1:8000/redoc" class="external-link" target="_blank">http://127.0.0.1:8000/redoc</a>.
👆 🔜 👀 🎛 🏧 🧾 (🚚 <a href="https://github.com/Rebilly/ReDoc" class="external-link" target="_blank">📄</a>):
![ReDoc](https://fastapi.tiangolo.com/img/index/index-02-redoc-simple.png)
## 🖼 ♻
🔜 🔀 📁 `main.py` 📨 💪 ⚪️➡️ `PUT` 📨.
📣 💪 ⚙️ 🐩 🐍 🆎, 👏 Pydantic.
```Python hl_lines="4 9-12 25-27"
from typing import Union
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
is_offer: Union[bool, None] = None
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id}
```
💽 🔜 🔃 🔁 (↩️ 👆 🚮 `--reload` `uvicorn` 📋 🔛).
### 🎓 🛠️ 🩺 ♻
🔜 🚶 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
* 🎓 🛠️ 🧾 🔜 🔁 ℹ, 🔌 🆕 💪:
![Swagger UI](https://fastapi.tiangolo.com/img/index/index-03-swagger-02.png)
* 🖊 🔛 🔼 "🔄 ⚫️ 👅", ⚫️ ✔ 👆 🥧 🔢 &amp; 🔗 🔗 ⏮️ 🛠️:
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-04-swagger-03.png)
* ⤴️ 🖊 🔛 "🛠️" 🔼, 👩‍💻 🔢 🔜 🔗 ⏮️ 👆 🛠️, 📨 🔢, 🤚 🏁 &amp; 🎦 👫 🔛 🖥:
![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-05-swagger-04.png)
### 🎛 🛠️ 🩺 ♻
&amp; 🔜, 🚶 <a href="http://127.0.0.1:8000/redoc" class="external-link" target="_blank">http://127.0.0.1:8000/redoc</a>.
* 🎛 🧾 🔜 🎨 🆕 🔢 🔢 &amp; 💪:
![ReDoc](https://fastapi.tiangolo.com/img/index/index-06-redoc-02.png)
### 🌃
📄, 👆 📣 **🕐** 🆎 🔢, 💪, ♒️. 🔢 🔢.
👆 👈 ⏮️ 🐩 🏛 🐍 🆎.
👆 🚫 ✔️ 💡 🆕 ❕, 👩‍🔬 ⚖️ 🎓 🎯 🗃, ♒️.
🐩 **🐍 3️⃣.7️⃣ ➕**.
🖼, `int`:
```Python
item_id: int
```
⚖️ 🌖 🏗 `Item` 🏷:
```Python
item: Item
```
...&amp; ⏮️ 👈 👁 📄 👆 🤚:
* 👨‍🎨 🐕‍🦺, 🔌:
* 🛠️.
* 🆎 ✅.
* 🔬 💽:
* 🏧 &amp; 🆑 ❌ 🕐❔ 📊 ❌.
* 🔬 🙇 🐦 🎻 🎚.
* <abbr title="also known as: serialization, parsing, marshalling">🛠️</abbr> 🔢 💽: 👟 ⚪️➡️ 🕸 🐍 💽 &amp; 🆎. 👂 ⚪️➡️:
* 🎻.
* ➡ 🔢.
* 🔢 🔢.
* 🍪.
* 🎚.
* 📨.
* 📁.
* <abbr title="also known as: serialization, parsing, marshalling">🛠️</abbr> 🔢 📊: 🗜 ⚪️➡️ 🐍 💽 &amp; 🆎 🕸 💽 (🎻):
* 🗜 🐍 🆎 (`str`, `int`, `float`, `bool`, `list`, ♒️).
* `datetime` 🎚.
* `UUID` 🎚.
* 💽 🏷.
* ...&amp; 📚 🌖.
* 🏧 🎓 🛠️ 🧾, 🔌 2️⃣ 🎛 👩‍💻 🔢:
* 🦁 🎚.
* 📄.
---
👟 🔙 ⏮️ 📟 🖼, **FastAPI** 🔜:
* ✔ 👈 📤 `item_id``GET` &amp; `PUT` 📨.
* ✔ 👈 `item_id` 🆎 `int` `GET` &amp; `PUT` 📨.
* 🚥 ⚫️ 🚫, 👩‍💻 🔜 👀 ⚠, 🆑 ❌.
* ✅ 🚥 📤 📦 🔢 🔢 📛 `q` ( `http://127.0.0.1:8000/items/foo?q=somequery`) `GET` 📨.
* `q` 🔢 📣 ⏮️ `= None`, ⚫️ 📦.
* 🍵 `None` ⚫️ 🔜 🚚 (💪 💼 ⏮️ `PUT`).
* `PUT` 📨 `/items/{item_id}`, ✍ 💪 🎻:
* ✅ 👈 ⚫️ ✔️ ✔ 🔢 `name` 👈 🔜 `str`.
* ✅ 👈 ⚫️ ✔️ ✔ 🔢 `price` 👈 ✔️ `float`.
* ✅ 👈 ⚫️ ✔️ 📦 🔢 `is_offer`, 👈 🔜 `bool`, 🚥 🎁.
* 🌐 👉 🔜 👷 🙇 🐦 🎻 🎚.
* 🗜 ⚪️➡️ &amp; 🎻 🔁.
* 📄 🌐 ⏮️ 🗄, 👈 💪 ⚙️:
* 🎓 🧾 ⚙️.
* 🏧 👩‍💻 📟 ⚡ ⚙️, 📚 🇪🇸.
* 🚚 2️⃣ 🎓 🧾 🕸 🔢 🔗.
---
👥 🖌 🧽, ✋️ 👆 ⏪ 🤚 💭 ❔ ⚫️ 🌐 👷.
🔄 🔀 ⏸ ⏮️:
```Python
return {"item_name": item.name, "item_id": item_id}
```
...⚪️➡️:
```Python
... "item_name": item.name ...
```
...:
```Python
... "item_price": item.price ...
```
...&amp; 👀 ❔ 👆 👨‍🎨 🔜 🚘-🏁 🔢 &amp; 💭 👫 🆎:
![editor support](https://fastapi.tiangolo.com/img/vscode-completion.png)
🌅 🏁 🖼 🔌 🌅 ⚒, 👀 <a href="https://fastapi.tiangolo.com/tutorial/">🔰 - 👩‍💻 🦮</a>.
**🚘 🚨**: 🔰 - 👩‍💻 🦮 🔌:
* 📄 **🔢** ⚪️➡️ 🎏 🎏 🥉: **🎚**, **🍪**, **📨 🏑** &amp; **📁**.
* ❔ ⚒ **🔬 ⚛** `maximum_length` ⚖️ `regex`.
* 📶 🏋️ &amp; ⏩ ⚙️ **<abbr title="also known as components, resources, providers, services, injectables">🔗 💉</abbr>** ⚙️.
* 💂‍♂ &amp; 🤝, ✅ 🐕‍🦺 **Oauth2️⃣** ⏮️ **🥙 🤝** &amp; **🇺🇸🔍 🔰** 🔐.
* 🌅 🏧 (✋️ 😨 ⏩) ⚒ 📣 **🙇 🐦 🎻 🏷** (👏 Pydantic).
* **🕹** 🛠️ ⏮️ <a href="https://strawberry.rocks" class="external-link" target="_blank">🍓</a> &amp; 🎏 🗃.
* 📚 ➕ ⚒ (👏 💃):
* ** *️⃣ **
* 📶 ⏩ 💯 ⚓️ 🔛 🇸🇲 &amp; `pytest`
* **⚜**
* **🍪 🎉**
* ...&amp; 🌖.
## 🎭
🔬 🇸🇲 📇 🎦 **FastAPI** 🈸 🏃‍♂ 🔽 Uvicorn <a href="https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7" class="external-link" target="_blank">1️⃣ ⏩ 🐍 🛠️ 💪</a>, 🕴 🔛 💃 &amp; Uvicorn 👫 (⚙️ 🔘 FastAPI). (*)
🤔 🌖 🔃 ⚫️, 👀 📄 <a href="https://fastapi.tiangolo.com/benchmarks/" class="internal-link" target="_blank">📇</a>.
## 📦 🔗
⚙️ Pydantic:
* <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - ⏩ 🎻 <abbr title="converting the string that comes from an HTTP request into Python data">"🎻"</abbr>.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - 📧 🔬.
⚙️ 💃:
* <a href="https://www.python-httpx.org" target="_blank"><code>httpx</code></a> - ✔ 🚥 👆 💚 ⚙️ `TestClient`.
* <a href="https://jinja.palletsprojects.com" target="_blank"><code>jinja2</code></a> - ✔ 🚥 👆 💚 ⚙️ 🔢 📄 📳.
* <a href="https://andrew-d.github.io/python-multipart/" target="_blank"><code>python-multipart</code></a> - ✔ 🚥 👆 💚 🐕‍🦺 📨 <abbr title="converting the string that comes from an HTTP request into Python data">"✍"</abbr>, ⏮️ `request.form()`.
* <a href="https://pythonhosted.org/itsdangerous/" target="_blank"><code>itsdangerous</code></a> - ✔ `SessionMiddleware` 🐕‍🦺.
* <a href="https://pyyaml.org/wiki/PyYAMLDocumentation" target="_blank"><code>pyyaml</code></a> - ✔ 💃 `SchemaGenerator` 🐕‍🦺 (👆 🎲 🚫 💪 ⚫️ ⏮️ FastAPI).
* <a href="https://github.com/esnme/ultrajson" target="_blank"><code>ujson</code></a> - ✔ 🚥 👆 💚 ⚙️ `UJSONResponse`.
⚙️ FastAPI / 💃:
* <a href="https://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - 💽 👈 📐 &amp; 🍦 👆 🈸.
* <a href="https://github.com/ijl/orjson" target="_blank"><code>orjson</code></a> - ✔ 🚥 👆 💚 ⚙️ `ORJSONResponse`.
👆 💪 ❎ 🌐 👫 ⏮️ `pip install "fastapi[all]"`.
## 🛂
👉 🏗 ® 🔽 ⚖ 🇩🇪 🛂.

84
docs/em/docs/project-generation.md

@ -0,0 +1,84 @@
# 🏗 ⚡ - 📄
👆 💪 ⚙️ 🏗 🚂 🤚 ▶️, ⚫️ 🔌 📚 ▶️ ⚒ 🆙, 💂‍♂, 💽 &amp; 🛠️ 🔗 ⏪ ⌛ 👆.
🏗 🚂 🔜 🕧 ✔️ 📶 🙃 🖥 👈 👆 🔜 ℹ &amp; 🛠️ 👆 👍 💪, ✋️ ⚫️ 💪 👍 ▶️ ☝ 👆 🏗.
## 🌕 📚 FastAPI ✳
📂: <a href="https://github.com/tiangolo/full-stack-fastapi-postgresql" class="external-link" target="_blank">https://github.com/tiangolo/full-stack-fastapi-postgresql</a>
### 🌕 📚 FastAPI ✳ - ⚒
* 🌕 **☁** 🛠️ (☁ 🧢).
* ☁ 🐝 📳 🛠️.
* **☁ ✍** 🛠️ &amp; 🛠️ 🇧🇿 🛠️.
* **🏭 🔜** 🐍 🕸 💽 ⚙️ Uvicorn &amp; 🐁.
* 🐍 <a href="https://github.com/tiangolo/fastapi" class="external-link" target="_blank">**FastAPI**</a> 👩‍💻:
* **⏩**: 📶 ↕ 🎭, 🔛 🇷🇪 ⏮️ **✳** &amp; **🚶** (👏 💃 &amp; Pydantic).
* **🏋️**: 👑 👨‍🎨 🐕‍🦺. <abbr title="also known as auto-complete, autocompletion, IntelliSense">🛠️</abbr> 🌐. 🌘 🕰 🛠️.
* **⏩**: 🔧 ⏩ ⚙️ &amp; 💡. 🌘 🕰 👂 🩺.
* **📏**: 📉 📟 ❎. 💗 ⚒ ⚪️➡️ 🔠 🔢 📄.
* **🏋️**: 🤚 🏭-🔜 📟. ⏮️ 🏧 🎓 🧾.
* **🐩-⚓️**: ⚓️ 🔛 (&amp; 🍕 🔗 ⏮️) 📂 🐩 🔗: <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank">🗄</a> &amp; <a href="https://json-schema.org/" class="external-link" target="_blank">🎻 🔗</a>.
* <a href="https://fastapi.tiangolo.com/features/" class="external-link" target="_blank">**📚 🎏 ⚒**</a> 🔌 🏧 🔬, 🛠️, 🎓 🧾, 🤝 ⏮️ Oauth2️⃣ 🥙 🤝, ♒️.
* **🔐 🔐** 🔁 🔢.
* **🥙 🤝** 🤝.
* **🇸🇲** 🏷 (🔬 🏺 ↔, 👫 💪 ⚙️ ⏮️ 🥒 👨‍🏭 🔗).
* 🔰 ▶️ 🏷 👩‍💻 (🔀 &amp; ❎ 👆 💪).
* **⚗** 🛠️.
* **⚜** (✖️ 🇨🇳 ℹ 🤝).
* **🥒** 👨‍🏭 👈 💪 🗄 &amp; ⚙️ 🏷 &amp; 📟 ⚪️➡️ 🎂 👩‍💻 🍕.
* 🎂 👩‍💻 💯 ⚓️ 🔛 **✳**, 🛠️ ⏮️ ☁, 👆 💪 💯 🌕 🛠️ 🔗, 🔬 🔛 💽. ⚫️ 🏃 ☁, ⚫️ 💪 🏗 🆕 💽 🏪 ⚪️➡️ 🖌 🔠 🕰 (👆 💪 ⚙️ ✳, ✳, ✳, ⚖️ ⚫️❔ 👆 💚, &amp; 💯 👈 🛠️ 👷).
* ⏩ 🐍 🛠️ ⏮️ **📂 💾** 🛰 ⚖️-☁ 🛠️ ⏮️ ↔ 💖 ⚛ ⚗ ⚖️ 🎙 🎙 📟 📂.
* **🎦** 🕸:
* 🏗 ⏮️ 🎦 ✳.
* **🥙 🤝** 🚚.
* 💳 🎑.
* ⏮️ 💳, 👑 🕹 🎑.
* 👑 🕹 ⏮️ 👩‍💻 🏗 &amp; 📕.
* 👤 👩‍💻 📕.
* **🇷🇪**.
* **🎦-📻**.
* **Vuetify** 🌹 🧽 🔧 🦲.
* **📕**.
* ☁ 💽 ⚓️ 🔛 **👌** (📶 🤾 🎆 ⏮️ 🎦-📻).
* ☁ 👁-▶️ 🏗, 👆 🚫 💪 🖊 ⚖️ 💕 ✍ 📟.
* 🕸 💯 🏃 🏗 🕰 (💪 🔕 💁‍♂️).
* ⚒ 🔧 💪, ⚫️ 👷 👅 📦, ✋️ 👆 💪 🏤-🏗 ⏮️ 🎦 ✳ ⚖️ ✍ ⚫️ 👆 💪, &amp; 🏤-⚙️ ⚫️❔ 👆 💚.
* ** *️⃣ ** ✳ 💽, 👆 💪 🔀 ⚫️ ⚙️ 📁 &amp; ✳ 💪.
* **🥀** 🥒 👨‍🏭 ⚖.
* 📐 ⚖ 🖖 🕸 &amp; 👩‍💻 ⏮️ **Traefik**, 👆 💪 ✔️ 👯‍♂️ 🔽 🎏 🆔, 👽 ➡, ✋️ 🍦 🎏 📦.
* Traefik 🛠️, ✅ ➡️ 🗜 **🇺🇸🔍** 📄 🏧 ⚡.
* ✳ **🆑** (🔁 🛠️), 🔌 🕸 &amp; 👩‍💻 🔬.
## 🌕 📚 FastAPI 🗄
📂: <a href="https://github.com/tiangolo/full-stack-fastapi-couchbase" class="external-link" target="_blank">https://github.com/tiangolo/full-stack-fastapi-couchbase</a>
👶 👶 **⚠** 👶 👶
🚥 👆 ▶️ 🆕 🏗 ⚪️➡️ 🖌, ✅ 🎛 📥.
🖼, 🏗 🚂 <a href="https://github.com/tiangolo/full-stack-fastapi-postgresql" class="external-link" target="_blank">🌕 📚 FastAPI ✳</a> 💪 👍 🎛, ⚫️ 🎯 🚧 &amp; ⚙️. &amp; ⚫️ 🔌 🌐 🆕 ⚒ &amp; 📈.
👆 🆓 ⚙️ 🗄-⚓️ 🚂 🚥 👆 💚, ⚫️ 🔜 🎲 👷 👌, &amp; 🚥 👆 ⏪ ✔️ 🏗 🏗 ⏮️ ⚫️ 👈 👌 👍 (&amp; 👆 🎲 ⏪ ℹ ⚫️ ♣ 👆 💪).
👆 💪 ✍ 🌅 🔃 ⚫️ 🩺 🏦.
## 🌕 📚 FastAPI ✳
...💪 👟 ⏪, ⚓️ 🔛 👇 🕰 🚚 &amp; 🎏 ⚖. 👶 👶
## 🎰 🏫 🏷 ⏮️ 🌈 &amp; FastAPI
📂: <a href="https://github.com/microsoft/cookiecutter-spacy-fastapi" class="external-link" target="_blank">https://github.com/microsoft/cookiecutter-spacy-fastapi</a>
### 🎰 🏫 🏷 ⏮️ 🌈 &amp; FastAPI - ⚒
* **🌈** 🕜 🏷 🛠️.
* **☁ 🧠 🔎** 📨 📁 🏗.
* **🏭 🔜** 🐍 🕸 💽 ⚙️ Uvicorn &amp; 🐁.
* **☁ 👩‍💻** Kubernete (🦲) 🆑/💿 🛠️ 🏗.
* **🤸‍♂** 💪 ⚒ 1️⃣ 🌈 🏗 🇪🇸 ⏮️ 🏗 🖥.
* **💪 🏧** 🎏 🏷 🛠️ (Pytorch, 🇸🇲), 🚫 🌈.

490
docs/em/docs/python-types.md

@ -0,0 +1,490 @@
# 🐍 🆎 🎶
🐍 ✔️ 🐕‍🦺 📦 "🆎 🔑".
👫 **"🆎 🔑"** 🎁 ❕ 👈 ✔ 📣 <abbr title="for example: str, int, float, bool">🆎</abbr> 🔢.
📣 🆎 👆 🔢, 👨‍🎨 &amp; 🧰 💪 🤝 👆 👍 🐕‍🦺.
👉 **⏩ 🔰 / ↗️** 🔃 🐍 🆎 🔑. ⚫️ 📔 🕴 💯 💪 ⚙️ 👫 ⏮️ **FastAPI**... ❔ 🤙 📶 🐥.
**FastAPI** 🌐 ⚓️ 🔛 👫 🆎 🔑, 👫 🤝 ⚫️ 📚 📈 &amp; 💰.
✋️ 🚥 👆 🙅 ⚙️ **FastAPI**, 👆 🔜 💰 ⚪️➡️ 🏫 🍖 🔃 👫.
!!! note
🚥 👆 🐍 🕴, &amp; 👆 ⏪ 💭 🌐 🔃 🆎 🔑, 🚶 ⏭ 📃.
## 🎯
➡️ ▶️ ⏮️ 🙅 🖼:
```Python
{!../../../docs_src/python_types/tutorial001.py!}
```
🤙 👉 📋 🔢:
```
John Doe
```
🔢 🔨 📄:
* ✊ `first_name` &amp; `last_name`.
* 🗜 🥇 🔤 🔠 1️⃣ ↖ 💼 ⏮️ `title()`.
* <abbr title="Puts them together, as one. With the contents of one after the other.">🔢</abbr> 👫 ⏮️ 🚀 🖕.
```Python hl_lines="2"
{!../../../docs_src/python_types/tutorial001.py!}
```
### ✍ ⚫️
⚫️ 📶 🙅 📋.
✋️ 🔜 🌈 👈 👆 ✍ ⚫️ ⚪️➡️ 🖌.
☝ 👆 🔜 ✔️ ▶️ 🔑 🔢, 👆 ✔️ 🔢 🔜...
✋️ ⤴️ 👆 ✔️ 🤙 "👈 👩‍🔬 👈 🗜 🥇 🔤 ↖ 💼".
⚫️ `upper`❓ ⚫️ `uppercase``first_uppercase``capitalize`
⤴️, 👆 🔄 ⏮️ 🗝 👩‍💻 👨‍👧‍👦, 👨‍🎨 ✍.
👆 🆎 🥇 🔢 🔢, `first_name`, ⤴️ ❣ (`.`) &amp; ⤴️ 🎯 `Ctrl+Space` ⏲ 🛠️.
✋️, 😞, 👆 🤚 🕳 ⚠:
<img src="/img/python-types/image01.png">
### 🚮 🆎
➡️ 🔀 👁 ⏸ ⚪️➡️ ⏮️ ⏬.
👥 🔜 🔀 ⚫️❔ 👉 🧬, 🔢 🔢, ⚪️➡️:
```Python
first_name, last_name
```
:
```Python
first_name: str, last_name: str
```
👈 ⚫️.
👈 "🆎 🔑":
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial002.py!}
```
👈 🚫 🎏 📣 🔢 💲 💖 🔜 ⏮️:
```Python
first_name="john", last_name="doe"
```
⚫️ 🎏 👜.
👥 ⚙️ ❤ (`:`), 🚫 🌓 (`=`).
&amp; ❎ 🆎 🔑 🛎 🚫 🔀 ⚫️❔ 🔨 ⚪️➡️ ⚫️❔ 🔜 🔨 🍵 👫.
✋️ 🔜, 🌈 👆 🔄 🖕 🏗 👈 🔢, ✋️ ⏮️ 🆎 🔑.
🎏 ☝, 👆 🔄 ⏲ 📋 ⏮️ `Ctrl+Space` &amp; 👆 👀:
<img src="/img/python-types/image02.png">
⏮️ 👈, 👆 💪 📜, 👀 🎛, ⏭ 👆 🔎 1️⃣ 👈 "💍 🔔":
<img src="/img/python-types/image03.png">
## 🌅 🎯
✅ 👉 🔢, ⚫️ ⏪ ✔️ 🆎 🔑:
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial003.py!}
```
↩️ 👨‍🎨 💭 🆎 🔢, 👆 🚫 🕴 🤚 🛠️, 👆 🤚 ❌ ✅:
<img src="/img/python-types/image04.png">
🔜 👆 💭 👈 👆 ✔️ 🔧 ⚫️, 🗜 `age` 🎻 ⏮️ `str(age)`:
```Python hl_lines="2"
{!../../../docs_src/python_types/tutorial004.py!}
```
## 📣 🆎
👆 👀 👑 🥉 📣 🆎 🔑. 🔢 🔢.
👉 👑 🥉 👆 🔜 ⚙️ 👫 ⏮️ **FastAPI**.
### 🙅 🆎
👆 💪 📣 🌐 🐩 🐍 🆎, 🚫 🕴 `str`.
👆 💪 ⚙️, 🖼:
* `int`
* `float`
* `bool`
* `bytes`
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial005.py!}
```
### 💊 🆎 ⏮️ 🆎 🔢
📤 📊 📊 👈 💪 🔌 🎏 💲, 💖 `dict`, `list`, `set` &amp; `tuple`. &amp; 🔗 💲 💪 ✔️ 👫 👍 🆎 💁‍♂️.
👉 🆎 👈 ✔️ 🔗 🆎 🤙 "**💊**" 🆎. &amp; ⚫️ 💪 📣 👫, ⏮️ 👫 🔗 🆎.
📣 👈 🆎 &amp; 🔗 🆎, 👆 💪 ⚙️ 🐩 🐍 🕹 `typing`. ⚫️ 🔀 🎯 🐕‍🦺 👫 🆎 🔑.
#### 🆕 ⏬ 🐍
❕ ⚙️ `typing` **🔗** ⏮️ 🌐 ⏬, ⚪️➡️ 🐍 3️⃣.6️⃣ ⏪ 🕐, ✅ 🐍 3️⃣.9️⃣, 🐍 3️⃣.1️⃣0️⃣, ♒️.
🐍 🏧, **🆕 ⏬** 👟 ⏮️ 📉 🐕‍🦺 👉 🆎 ✍ &amp; 📚 💼 👆 🏆 🚫 💪 🗄 &amp; ⚙️ `typing` 🕹 📣 🆎 ✍.
🚥 👆 💪 ⚒ 🌖 ⏮️ ⏬ 🐍 👆 🏗, 👆 🔜 💪 ✊ 📈 👈 ➕ 🦁. 👀 🖼 🔛.
#### 📇
🖼, ➡️ 🔬 🔢 `list` `str`.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
⚪️➡️ `typing`, 🗄 `List` (⏮️ 🔠 `L`):
``` Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial006.py!}
```
📣 🔢, ⏮️ 🎏 ❤ (`:`) ❕.
🆎, 🚮 `List` 👈 👆 🗄 ⚪️➡️ `typing`.
📇 🆎 👈 🔌 🔗 🆎, 👆 🚮 👫 ⬜ 🗜:
```Python hl_lines="4"
{!> ../../../docs_src/python_types/tutorial006.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
📣 🔢, ⏮️ 🎏 ❤ (`:`) ❕.
🆎, 🚮 `list`.
📇 🆎 👈 🔌 🔗 🆎, 👆 🚮 👫 ⬜ 🗜:
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial006_py39.py!}
```
!!! info
👈 🔗 🆎 ⬜ 🗜 🤙 "🆎 🔢".
👉 💼, `str` 🆎 🔢 🚶‍♀️ `List` (⚖️ `list` 🐍 3️⃣.9️⃣ &amp; 🔛).
👈 ⛓: "🔢 `items` `list`, &amp; 🔠 🏬 👉 📇 `str`".
!!! tip
🚥 👆 ⚙️ 🐍 3️⃣.9️⃣ ⚖️ 🔛, 👆 🚫 ✔️ 🗄 `List` ⚪️➡️ `typing`, 👆 💪 ⚙️ 🎏 🥔 `list` 🆎 ↩️.
🔨 👈, 👆 👨‍🎨 💪 🚚 🐕‍🦺 ⏪ 🏭 🏬 ⚪️➡️ 📇:
<img src="/img/python-types/image05.png">
🍵 🆎, 👈 🌖 💪 🏆.
👀 👈 🔢 `item` 1️⃣ 🔣 📇 `items`.
&amp; , 👨‍🎨 💭 ⚫️ `str`, &amp; 🚚 🐕‍🦺 👈.
#### 🔢 &amp;
👆 🔜 🎏 📣 `tuple`&amp; `set`Ⓜ:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial007_py39.py!}
```
👉 ⛓:
* 🔢 `items_t` `tuple` ⏮️ 3️⃣ 🏬, `int`, ➕1️⃣ `int`, &amp; `str`.
* 🔢 `items_s` `set`, &amp; 🔠 🚮 🏬 🆎 `bytes`.
#### #️
🔬 `dict`, 👆 🚶‍♀️ 2️⃣ 🆎 🔢, 🎏 ❕.
🥇 🆎 🔢 🔑 `dict`.
🥈 🆎 🔢 💲 `dict`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial008_py39.py!}
```
👉 ⛓:
* 🔢 `prices` `dict`:
* 🔑 👉 `dict` 🆎 `str` (➡️ 💬, 📛 🔠 🏬).
* 💲 👉 `dict` 🆎 `float` (➡️ 💬, 🔖 🔠 🏬).
#### 🇪🇺
👆 💪 📣 👈 🔢 💪 🙆 **📚 🆎**, 🖼, `int` ⚖️ `str`.
🐍 3️⃣.6️⃣ &amp; 🔛 (✅ 🐍 3️⃣.1️⃣0️⃣) 👆 💪 ⚙️ `Union` 🆎 ⚪️➡️ `typing` &amp; 🚮 🔘 ⬜ 🗜 💪 🆎 🚫.
🐍 3️⃣.1️⃣0️⃣ 📤 **🎛 ❕** 🌐❔ 👆 💪 🚮 💪 🆎 👽 <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>⏸ ⏸ (`|`)</abbr>.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial008b_py310.py!}
```
👯‍♂️ 💼 👉 ⛓ 👈 `item` 💪 `int` ⚖️ `str`.
#### 🎲 `None`
👆 💪 📣 👈 💲 💪 ✔️ 🆎, 💖 `str`, ✋️ 👈 ⚫️ 💪 `None`.
🐍 3️⃣.6️⃣ &amp; 🔛 (✅ 🐍 3️⃣.1️⃣0️⃣) 👆 💪 📣 ⚫️ 🏭 &amp; ⚙️ `Optional` ⚪️➡️ `typing` 🕹.
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009.py!}
```
⚙️ `Optional[str]` ↩️ `str` 🔜 ➡️ 👨‍🎨 ℹ 👆 🔍 ❌ 🌐❔ 👆 💪 🤔 👈 💲 🕧 `str`, 🕐❔ ⚫️ 💪 🤙 `None` 💁‍♂️.
`Optional[Something]` 🤙 ⌨ `Union[Something, None]`, 👫 🌓.
👉 ⛓ 👈 🐍 3️⃣.1️⃣0️⃣, 👆 💪 ⚙️ `Something | None`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
```
=== "🐍 3️⃣.6️⃣ &amp; 🔛 - 🎛"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial009_py310.py!}
```
#### ⚙️ `Union` ⚖️ `Optional`
🚥 👆 ⚙️ 🐍 ⏬ 🔛 3️⃣.1️⃣0️⃣, 📥 💁‍♂ ⚪️➡️ 👇 📶 **🤔** ☝ 🎑:
* 👶 ❎ ⚙️ `Optional[SomeType]`
* ↩️ 👶 **⚙️ `Union[SomeType, None]`** 👶.
👯‍♂️ 🌓 &amp; 🔘 👫 🎏, ✋️ 👤 🔜 👍 `Union` ↩️ `Optional` ↩️ 🔤 "**📦**" 🔜 😑 🔑 👈 💲 📦, &amp; ⚫️ 🤙 ⛓ "⚫️ 💪 `None`", 🚥 ⚫️ 🚫 📦 &amp; ✔.
👤 💭 `Union[SomeType, None]` 🌖 🔑 🔃 ⚫️❔ ⚫️ ⛓.
⚫️ 🔃 🔤 &amp; 📛. ✋️ 👈 🔤 💪 📉 ❔ 👆 &amp; 👆 🤽‍♂ 💭 🔃 📟.
🖼, ➡️ ✊ 👉 🔢:
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009c.py!}
```
🔢 `name` 🔬 `Optional[str]`, ✋️ ⚫️ **🚫 📦**, 👆 🚫🔜 🤙 🔢 🍵 🔢:
```Python
say_hi() # Oh, no, this throws an error! 😱
```
`name` 🔢 **✔** (🚫 *📦*) ↩️ ⚫️ 🚫 ✔️ 🔢 💲. , `name` 🚫 `None` 💲:
```Python
say_hi(name=None) # This works, None is valid 🎉
```
👍 📰, 🕐 👆 🔛 🐍 3️⃣.1️⃣0️⃣ 👆 🏆 🚫 ✔️ 😟 🔃 👈, 👆 🔜 💪 🎯 ⚙️ `|` 🔬 🇪🇺 🆎:
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009c_py310.py!}
```
&amp; ⤴️ 👆 🏆 🚫 ✔️ 😟 🔃 📛 💖 `Optional` &amp; `Union`. 👶
#### 💊 🆎
👉 🆎 👈 ✊ 🆎 🔢 ⬜ 🗜 🤙 **💊 🆎** ⚖️ **💊**, 🖼:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
* `List`
* `Tuple`
* `Set`
* `Dict`
* `Union`
* `Optional`
* ...&amp; 🎏.
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
👆 💪 ⚙️ 🎏 💽 🆎 💊 (⏮️ ⬜ 🗜 &amp; 🆎 🔘):
* `list`
* `tuple`
* `set`
* `dict`
&amp; 🎏 ⏮️ 🐍 3️⃣.6️⃣, ⚪️➡️ `typing` 🕹:
* `Union`
* `Optional`
* ...&amp; 🎏.
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
👆 💪 ⚙️ 🎏 💽 🆎 💊 (⏮️ ⬜ 🗜 &amp; 🆎 🔘):
* `list`
* `tuple`
* `set`
* `dict`
&amp; 🎏 ⏮️ 🐍 3️⃣.6️⃣, ⚪️➡️ `typing` 🕹:
* `Union`
* `Optional` (🎏 ⏮️ 🐍 3️⃣.6️⃣)
* ...&amp; 🎏.
🐍 3️⃣.1️⃣0️⃣, 🎛 ⚙️ 💊 `Union` &amp; `Optional`, 👆 💪 ⚙️ <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>⏸ ⏸ (`|`)</abbr> 📣 🇪🇺 🆎.
### 🎓 🆎
👆 💪 📣 🎓 🆎 🔢.
➡️ 💬 👆 ✔️ 🎓 `Person`, ⏮️ 📛:
```Python hl_lines="1-3"
{!../../../docs_src/python_types/tutorial010.py!}
```
⤴️ 👆 💪 📣 🔢 🆎 `Person`:
```Python hl_lines="6"
{!../../../docs_src/python_types/tutorial010.py!}
```
&amp; ⤴️, 🔄, 👆 🤚 🌐 👨‍🎨 🐕‍🦺:
<img src="/img/python-types/image06.png">
## Pydantic 🏷
<a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> 🐍 🗃 🎭 📊 🔬.
👆 📣 "💠" 💽 🎓 ⏮️ 🔢.
&amp; 🔠 🔢 ✔️ 🆎.
⤴️ 👆 ✍ 👐 👈 🎓 ⏮️ 💲 &amp; ⚫️ 🔜 ✔ 💲, 🗜 👫 ☑ 🆎 (🚥 👈 💼) &amp; 🤝 👆 🎚 ⏮️ 🌐 💽.
&amp; 👆 🤚 🌐 👨‍🎨 🐕‍🦺 ⏮️ 👈 📉 🎚.
🖼 ⚪️➡️ 🛂 Pydantic 🩺:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python
{!> ../../../docs_src/python_types/tutorial011_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python
{!> ../../../docs_src/python_types/tutorial011_py310.py!}
```
!!! info
💡 🌖 🔃 <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic, ✅ 🚮 🩺</a>.
**FastAPI** 🌐 ⚓️ 🔛 Pydantic.
👆 🔜 👀 📚 🌅 🌐 👉 💡 [🔰 - 👩‍💻 🦮](tutorial/index.md){.internal-link target=_blank}.
!!! tip
Pydantic ✔️ 🎁 🎭 🕐❔ 👆 ⚙️ `Optional` ⚖️ `Union[Something, None]` 🍵 🔢 💲, 👆 💪 ✍ 🌅 🔃 ⚫️ Pydantic 🩺 🔃 <a href="https://pydantic-docs.helpmanual.io/usage/models/#required-optional-fields" class="external-link" target="_blank">✔ 📦 🏑</a>.
## 🆎 🔑 **FastAPI**
**FastAPI** ✊ 📈 👫 🆎 🔑 📚 👜.
⏮️ **FastAPI** 👆 📣 🔢 ⏮️ 🆎 🔑 &amp; 👆 🤚:
* **👨‍🎨 🐕‍🦺**.
* **🆎 ✅**.
...and **FastAPI** uses the same declarations :
* **🔬 📄**: ⚪️➡️ 📨 ➡ 🔢, 🔢 🔢, 🎚, 💪, 🔗, ♒️.
* **🗜 💽**: ⚪️➡️ 📨 🚚 🆎.
* **✔ 💽**: 👟 ⚪️➡️ 🔠 📨:
* 🏭 **🏧 ❌** 📨 👩‍💻 🕐❔ 📊 ❌.
* **📄** 🛠️ ⚙️ 🗄:
* ❔ ⤴️ ⚙️ 🏧 🎓 🧾 👩‍💻 🔢.
👉 5️⃣📆 🌐 🔊 📝. 🚫 😟. 👆 🔜 👀 🌐 👉 🎯 [🔰 - 👩‍💻 🦮](tutorial/index.md){.internal-link target=_blank}.
⚠ 👜 👈 ⚙️ 🐩 🐍 🆎, 👁 🥉 (↩️ ❎ 🌖 🎓, 👨‍🎨, ♒️), **FastAPI** 🔜 📚 👷 👆.
!!! info
🚥 👆 ⏪ 🚶 🔘 🌐 🔰 &amp; 👟 🔙 👀 🌅 🔃 🆎, 👍 ℹ <a href="https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html" class="external-link" target="_blank"> "🎮 🎼" ⚪️➡️ `mypy`</a>.

102
docs/em/docs/tutorial/background-tasks.md

@ -0,0 +1,102 @@
# 🖥 📋
👆 💪 🔬 🖥 📋 🏃 *⏮️* 🛬 📨.
👉 ⚠ 🛠️ 👈 💪 🔨 ⏮️ 📨, ✋️ 👈 👩‍💻 🚫 🤙 ✔️ ⌛ 🛠️ 🏁 ⏭ 📨 📨.
👉 🔌, 🖼:
* 📧 📨 📨 ⏮️ 🎭 🎯:
* 🔗 📧 💽 &amp; 📨 📧 😑 "🐌" (📚 🥈), 👆 💪 📨 📨 ▶️️ ↖️ &amp; 📨 📧 📨 🖥.
* 🏭 💽:
* 🖼, ➡️ 💬 👆 📨 📁 👈 🔜 🚶 🔘 🐌 🛠️, 👆 💪 📨 📨 "🚫" (🇺🇸🔍 2️⃣0️⃣2️⃣) &amp; 🛠️ ⚫️ 🖥.
## ⚙️ `BackgroundTasks`
🥇, 🗄 `BackgroundTasks` &amp; 🔬 🔢 👆 *➡ 🛠️ 🔢* ⏮️ 🆎 📄 `BackgroundTasks`:
```Python hl_lines="1 13"
{!../../../docs_src/background_tasks/tutorial001.py!}
```
**FastAPI** 🔜 ✍ 🎚 🆎 `BackgroundTasks` 👆 &amp; 🚶‍♀️ ⚫️ 👈 🔢.
## ✍ 📋 🔢
✍ 🔢 🏃 🖥 📋.
⚫️ 🐩 🔢 👈 💪 📨 🔢.
⚫️ 💪 `async def` ⚖️ 😐 `def` 🔢, **FastAPI** 🔜 💭 ❔ 🍵 ⚫️ ☑.
👉 💼, 📋 🔢 🔜 ✍ 📁 (⚖ 📨 📧).
&amp; ✍ 🛠️ 🚫 ⚙️ `async` &amp; `await`, 👥 🔬 🔢 ⏮️ 😐 `def`:
```Python hl_lines="6-9"
{!../../../docs_src/background_tasks/tutorial001.py!}
```
## 🚮 🖥 📋
🔘 👆 *➡ 🛠️ 🔢*, 🚶‍♀️ 👆 📋 🔢 *🖥 📋* 🎚 ⏮️ 👩‍🔬 `.add_task()`:
```Python hl_lines="14"
{!../../../docs_src/background_tasks/tutorial001.py!}
```
`.add_task()` 📨 ❌:
* 📋 🔢 🏃 🖥 (`write_notification`).
* 🙆 🔁 ❌ 👈 🔜 🚶‍♀️ 📋 🔢 ✔ (`email`).
* 🙆 🇨🇻 ❌ 👈 🔜 🚶‍♀️ 📋 🔢 (`message="some notification"`).
## 🔗 💉
⚙️ `BackgroundTasks` 👷 ⏮️ 🔗 💉 ⚙️, 👆 💪 📣 🔢 🆎 `BackgroundTasks` 💗 🎚: *➡ 🛠️ 🔢*, 🔗 (☑), 🎧-🔗, ♒️.
**FastAPI** 💭 ⚫️❔ 🔠 💼 &amp; ❔ 🏤-⚙️ 🎏 🎚, 👈 🌐 🖥 📋 🔗 👯‍♂️ &amp; 🏃 🖥 ⏮️:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="13 15 22 25"
{!> ../../../docs_src/background_tasks/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="11 13 20 23"
{!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
```
👉 🖼, 📧 🔜 ✍ `log.txt` 📁 *⏮️* 📨 📨.
🚥 📤 🔢 📨, ⚫️ 🔜 ✍ 🕹 🖥 📋.
&amp; ⤴️ ➕1️⃣ 🖥 📋 🏗 *➡ 🛠️ 🔢* 🔜 ✍ 📧 ⚙️ `email` ➡ 🔢.
## 📡 ℹ
🎓 `BackgroundTasks` 👟 🔗 ⚪️➡️ <a href="https://www.starlette.io/background/" class="external-link" target="_blank">`starlette.background`</a>.
⚫️ 🗄/🔌 🔗 🔘 FastAPI 👈 👆 💪 🗄 ⚫️ ⚪️➡️ `fastapi` &amp; ❎ 😫 🗄 🎛 `BackgroundTask` (🍵 `s` 🔚) ⚪️➡️ `starlette.background`.
🕴 ⚙️ `BackgroundTasks` (&amp; 🚫 `BackgroundTask`), ⚫️ ⤴️ 💪 ⚙️ ⚫️ *➡ 🛠️ 🔢* 🔢 &amp; ✔️ **FastAPI** 🍵 🎂 👆, 💖 🕐❔ ⚙️ `Request` 🎚 🔗.
⚫️ 💪 ⚙️ `BackgroundTask` 😞 FastAPI, ✋️ 👆 ✔️ ✍ 🎚 👆 📟 &amp; 📨 💃 `Response` 🔌 ⚫️.
👆 💪 👀 🌖 ℹ <a href="https://www.starlette.io/background/" class="external-link" target="_blank">💃 🛂 🩺 🖥 📋</a>.
## ⚠
🚥 👆 💪 🎭 🏋️ 🖥 📊 &amp; 👆 🚫 🎯 💪 ⚫️ 🏃 🎏 🛠️ (🖼, 👆 🚫 💪 💰 💾, 🔢, ♒️), 👆 💪 💰 ⚪️➡️ ⚙️ 🎏 🦏 🧰 💖 <a href="https://docs.celeryq.dev" class="external-link" target="_blank">🥒</a>.
👫 😑 🚚 🌖 🏗 📳, 📧/👨‍🏭 📤 👨‍💼, 💖 ✳ ⚖️ ✳, ✋️ 👫 ✔ 👆 🏃 🖥 📋 💗 🛠️, &amp; ✴️, 💗 💽.
👀 🖼, ✅ [🏗 🚂](../project-generation.md){.internal-link target=_blank}, 👫 🌐 🔌 🥒 ⏪ 📶.
✋️ 🚥 👆 💪 🔐 🔢 &amp; 🎚 ⚪️➡️ 🎏 **FastAPI** 📱, ⚖️ 👆 💪 🎭 🤪 🖥 📋 (💖 📨 📧 📨), 👆 💪 🎯 ⚙️ `BackgroundTasks`.
## 🌃
🗄 &amp; ⚙️ `BackgroundTasks` ⏮️ 🔢 *➡ 🛠️ 🔢* &amp; 🔗 🚮 🖥 📋.

488
docs/em/docs/tutorial/bigger-applications.md

@ -0,0 +1,488 @@
# 🦏 🈸 - 💗 📁
🚥 👆 🏗 🈸 ⚖️ 🕸 🛠️, ⚫️ 🛎 💼 👈 👆 💪 🚮 🌐 🔛 👁 📁.
**FastAPI** 🚚 🏪 🧰 📊 👆 🈸 ⏪ 🚧 🌐 💪.
!!! info
🚥 👆 👟 ⚪️➡️ 🏺, 👉 🔜 🌓 🏺 📗.
## 🖼 📁 📊
➡️ 💬 👆 ✔️ 📁 📊 💖 👉:
```
.
├── app
│   ├── __init__.py
│   ├── main.py
│   ├── dependencies.py
│   └── routers
│   │ ├── __init__.py
│   │ ├── items.py
│   │ └── users.py
│   └── internal
│   ├── __init__.py
│   └── admin.py
```
!!! tip
📤 📚 `__init__.py` 📁: 1️⃣ 🔠 📁 ⚖️ 📁.
👉 ⚫️❔ ✔ 🏭 📟 ⚪️➡️ 1️⃣ 📁 🔘 ➕1️⃣.
🖼, `app/main.py` 👆 💪 ✔️ ⏸ 💖:
```
from app.routers import items
```
* `app` 📁 🔌 🌐. &amp; ⚫️ ✔️ 🛁 📁 `app/__init__.py`, ⚫️ "🐍 📦" (🗃 "🐍 🕹"): `app`.
* ⚫️ 🔌 `app/main.py` 📁. ⚫️ 🔘 🐍 📦 (📁 ⏮️ 📁 `__init__.py`), ⚫️ "🕹" 👈 📦: `app.main`.
* 📤 `app/dependencies.py` 📁, 💖 `app/main.py`, ⚫️ "🕹": `app.dependencies`.
* 📤 📁 `app/routers/` ⏮️ ➕1️⃣ 📁 `__init__.py`, ⚫️ "🐍 📦": `app.routers`.
* 📁 `app/routers/items.py` 🔘 📦, `app/routers/`,, ⚫️ 🔁: `app.routers.items`.
* 🎏 ⏮️ `app/routers/users.py`, ⚫️ ➕1️⃣ 🔁: `app.routers.users`.
* 📤 📁 `app/internal/` ⏮️ ➕1️⃣ 📁 `__init__.py`, ⚫️ ➕1️⃣ "🐍 📦": `app.internal`.
* &amp; 📁 `app/internal/admin.py` ➕1️⃣ 🔁: `app.internal.admin`.
<img src="/img/tutorial/bigger-applications/package.svg">
🎏 📁 📊 ⏮️ 🏤:
```
.
├── app # "app" is a Python package
│   ├── __init__.py # this file makes "app" a "Python package"
│   ├── main.py # "main" module, e.g. import app.main
│   ├── dependencies.py # "dependencies" module, e.g. import app.dependencies
│   └── routers # "routers" is a "Python subpackage"
│   │ ├── __init__.py # makes "routers" a "Python subpackage"
│   │ ├── items.py # "items" submodule, e.g. import app.routers.items
│   │ └── users.py # "users" submodule, e.g. import app.routers.users
│   └── internal # "internal" is a "Python subpackage"
│   ├── __init__.py # makes "internal" a "Python subpackage"
│   └── admin.py # "admin" submodule, e.g. import app.internal.admin
```
## `APIRouter`
➡️ 💬 📁 💡 🚚 👩‍💻 🔁 `/app/routers/users.py`.
👆 💚 ✔️ *➡ 🛠️* 🔗 👆 👩‍💻 👽 ⚪️➡️ 🎂 📟, 🚧 ⚫️ 🏗.
✋️ ⚫️ 🍕 🎏 **FastAPI** 🈸/🕸 🛠️ (⚫️ 🍕 🎏 "🐍 📦").
👆 💪 ✍ *➡ 🛠️* 👈 🕹 ⚙️ `APIRouter`.
### 🗄 `APIRouter`
👆 🗄 ⚫️ &amp; ✍ "👐" 🎏 🌌 👆 🔜 ⏮️ 🎓 `FastAPI`:
```Python hl_lines="1 3"
{!../../../docs_src/bigger_applications/app/routers/users.py!}
```
### *➡ 🛠️* ⏮️ `APIRouter`
&amp; ⤴️ 👆 ⚙️ ⚫️ 📣 👆 *➡ 🛠️*.
⚙️ ⚫️ 🎏 🌌 👆 🔜 ⚙️ `FastAPI` 🎓:
```Python hl_lines="6 11 16"
{!../../../docs_src/bigger_applications/app/routers/users.py!}
```
👆 💪 💭 `APIRouter` "🐩 `FastAPI`" 🎓.
🌐 🎏 🎛 🐕‍🦺.
🌐 🎏 `parameters`, `responses`, `dependencies`, `tags`, ♒️.
!!! tip
👉 🖼, 🔢 🤙 `router`, ✋️ 👆 💪 📛 ⚫️ 👐 👆 💚.
👥 🔜 🔌 👉 `APIRouter` 👑 `FastAPI` 📱, ✋️ 🥇, ➡️ ✅ 🔗 &amp; ➕1️⃣ `APIRouter`.
## 🔗
👥 👀 👈 👥 🔜 💪 🔗 ⚙️ 📚 🥉 🈸.
👥 🚮 👫 👫 👍 `dependencies` 🕹 (`app/dependencies.py`).
👥 🔜 🔜 ⚙️ 🙅 🔗 ✍ 🛃 `X-Token` 🎚:
```Python hl_lines="1 4-6"
{!../../../docs_src/bigger_applications/app/dependencies.py!}
```
!!! tip
👥 ⚙️ 💭 🎚 📉 👉 🖼.
✋️ 🎰 💼 👆 🔜 🤚 👍 🏁 ⚙️ 🛠️ [💂‍♂ 🚙](./security/index.md){.internal-link target=_blank}.
## ➕1️⃣ 🕹 ⏮️ `APIRouter`
➡️ 💬 👆 ✔️ 🔗 💡 🚚 "🏬" ⚪️➡️ 👆 🈸 🕹 `app/routers/items.py`.
👆 ✔️ *➡ 🛠️* :
* `/items/`
* `/items/{item_id}`
⚫️ 🌐 🎏 📊 ⏮️ `app/routers/users.py`.
✋️ 👥 💚 🙃 &amp; 📉 📟 🍖.
👥 💭 🌐 *➡ 🛠️* 👉 🕹 ✔️ 🎏:
* ➡ `prefix`: `/items`.
* `tags`: (1️⃣ 🔖: `items`).
* ➕ `responses`.
* `dependencies`: 👫 🌐 💪 👈 `X-Token` 🔗 👥 ✍.
, ↩️ ❎ 🌐 👈 🔠 *➡ 🛠️*, 👥 💪 🚮 ⚫️ `APIRouter`.
```Python hl_lines="5-10 16 21"
{!../../../docs_src/bigger_applications/app/routers/items.py!}
```
➡ 🔠 *➡ 🛠️* ✔️ ▶️ ⏮️ `/`, 💖:
```Python hl_lines="1"
@router.get("/{item_id}")
async def read_item(item_id: str):
...
```
...🔡 🔜 🚫 🔌 🏁 `/`.
, 🔡 👉 💼 `/items`.
👥 💪 🚮 📇 `tags` &amp;`responses` 👈 🔜 ✔ 🌐 *➡ 🛠️* 🔌 👉 📻.
&amp; 👥 💪 🚮 📇 `dependencies` 👈 🔜 🚮 🌐 *➡ 🛠️* 📻 &amp; 🔜 🛠️/❎ 🔠 📨 ⚒ 👫.
!!! tip
🗒 👈, 🌅 💖 [🔗 *➡ 🛠️ 👨‍🎨*](dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, 🙅‍♂ 💲 🔜 🚶‍♀️ 👆 *➡ 🛠️ 🔢*.
🔚 🏁 👈 🏬 ➡ 🔜:
* `/items/`
* `/items/{item_id}`
...👥 🎯.
* 👫 🔜 ™ ⏮️ 📇 🔖 👈 🔌 👁 🎻 `"items"`.
* 👫 "🔖" ✴️ ⚠ 🏧 🎓 🧾 ⚙️ (⚙️ 🗄).
* 🌐 👫 🔜 🔌 🔁 `responses`.
* 🌐 👫 *➡ 🛠️* 🔜 ✔️ 📇 `dependencies` 🔬/🛠️ ⏭ 👫.
* 🚥 👆 📣 🔗 🎯 *➡ 🛠️*, **👫 🔜 🛠️ 💁‍♂️**.
* 📻 🔗 🛠️ 🥇, ⤴️ [`dependencies` 👨‍🎨](dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, &amp; ⤴️ 😐 🔢 🔗.
* 👆 💪 🚮 [`Security` 🔗 ⏮️ `scopes`](../advanced/security/oauth2-scopes.md){.internal-link target=_blank}.
!!! tip
✔️ `dependencies` `APIRouter` 💪 ⚙️, 🖼, 🚚 🤝 🎂 👪 *➡ 🛠️*. 🚥 🔗 🚫 🚮 📦 🔠 1️⃣ 👫.
!!! check
`prefix`, `tags`, `responses`, &amp; `dependencies` 🔢 (📚 🎏 💼) ⚒ ⚪️➡️ **FastAPI** ℹ 👆 ❎ 📟 ❎.
### 🗄 🔗
👉 📟 👨‍❤‍👨 🕹 `app.routers.items`, 📁 `app/routers/items.py`.
&amp; 👥 💪 🤚 🔗 🔢 ⚪️➡️ 🕹 `app.dependencies`, 📁 `app/dependencies.py`.
👥 ⚙️ ⚖ 🗄 ⏮️ `..` 🔗:
```Python hl_lines="3"
{!../../../docs_src/bigger_applications/app/routers/items.py!}
```
#### ❔ ⚖ 🗄 👷
!!! tip
🚥 👆 💭 👌 ❔ 🗄 👷, 😣 ⏭ 📄 🔛.
👁 ❣ `.`, 💖:
```Python
from .dependencies import get_token_header
```
🔜 ⛓:
* ▶️ 🎏 📦 👈 👉 🕹 (📁 `app/routers/items.py`) 🖖 (📁 `app/routers/`)...
* 🔎 🕹 `dependencies` (👽 📁 `app/routers/dependencies.py`)...
* &amp; ⚪️➡️ ⚫️, 🗄 🔢 `get_token_header`.
✋️ 👈 📁 🚫 🔀, 👆 🔗 📁 `app/dependencies.py`.
💭 ❔ 👆 📱/📁 📊 👀 💖:
<img src="/img/tutorial/bigger-applications/package.svg">
---
2️⃣ ❣ `..`, 💖:
```Python
from ..dependencies import get_token_header
```
⛓:
* ▶️ 🎏 📦 👈 👉 🕹 (📁 `app/routers/items.py`) 🖖 (📁 `app/routers/`)...
* 🚶 👪 📦 (📁 `app/`)...
* &amp; 📤, 🔎 🕹 `dependencies` (📁 `app/dependencies.py`)...
* &amp; ⚪️➡️ ⚫️, 🗄 🔢 `get_token_header`.
👈 👷 ☑ ❗ 👶
---
🎏 🌌, 🚥 👥 ✔️ ⚙️ 3️⃣ ❣ `...`, 💖:
```Python
from ...dependencies import get_token_header
```
that 🔜 ⛓:
* ▶️ 🎏 📦 👈 👉 🕹 (📁 `app/routers/items.py`) 🖖 (📁 `app/routers/`)...
* 🚶 👪 📦 (📁 `app/`)...
* ⤴️ 🚶 👪 👈 📦 (📤 🙅‍♂ 👪 📦, `app` 🔝 🎚 👶)...
* &amp; 📤, 🔎 🕹 `dependencies` (📁 `app/dependencies.py`)...
* &amp; ⚪️➡️ ⚫️, 🗄 🔢 `get_token_header`.
👈 🔜 🔗 📦 🔛 `app/`, ⏮️ 🚮 👍 📁 `__init__.py`, ♒️. ✋️ 👥 🚫 ✔️ 👈. , 👈 🔜 🚮 ❌ 👆 🖼. 👶
✋️ 🔜 👆 💭 ❔ ⚫️ 👷, 👆 💪 ⚙️ ⚖ 🗄 👆 👍 📱 🙅‍♂ 🤔 ❔ 🏗 👫. 👶
### 🚮 🛃 `tags`, `responses`, &amp; `dependencies`
👥 🚫 ❎ 🔡 `/items` 🚫 `tags=["items"]` 🔠 *➡ 🛠️* ↩️ 👥 🚮 👫 `APIRouter`.
✋️ 👥 💪 🚮 _🌅_ `tags` 👈 🔜 ✔ 🎯 *➡ 🛠️*, &amp;`responses` 🎯 👈 *➡ 🛠️*:
```Python hl_lines="30-31"
{!../../../docs_src/bigger_applications/app/routers/items.py!}
```
!!! tip
👉 🏁 ➡ 🛠️ 🔜 ✔️ 🌀 🔖: `["items", "custom"]`.
&amp; ⚫️ 🔜 ✔️ 👯‍♂️ 📨 🧾, 1️⃣ `404` &amp; 1️⃣ `403`.
## 👑 `FastAPI`
🔜, ➡️ 👀 🕹 `app/main.py`.
📥 🌐❔ 👆 🗄 &amp; ⚙️ 🎓 `FastAPI`.
👉 🔜 👑 📁 👆 🈸 👈 👔 🌐 👯‍♂️.
&amp; 🏆 👆 ⚛ 🔜 🔜 🖖 🚮 👍 🎯 🕹, 👑 📁 🔜 🙅.
### 🗄 `FastAPI`
👆 🗄 &amp;`FastAPI` 🎓 🛎.
&amp; 👥 💪 📣 [🌐 🔗](dependencies/global-dependencies.md){.internal-link target=_blank} 👈 🔜 🌀 ⏮️ 🔗 🔠 `APIRouter`:
```Python hl_lines="1 3 7"
{!../../../docs_src/bigger_applications/app/main.py!}
```
### 🗄 `APIRouter`
🔜 👥 🗄 🎏 🔁 👈 ✔️ `APIRouter`Ⓜ:
```Python hl_lines="5"
{!../../../docs_src/bigger_applications/app/main.py!}
```
📁 `app/routers/users.py` &amp; `app/routers/items.py` 🔁 👈 🍕 🎏 🐍 📦 `app`, 👥 💪 ⚙️ 👁 ❣ `.` 🗄 👫 ⚙️ "⚖ 🗄".
### ❔ 🏭 👷
📄:
```Python
from .routers import items, users
```
⛓:
* ▶️ 🎏 📦 👈 👉 🕹 (📁 `app/main.py`) 🖖 (📁 `app/`)...
* 👀 📦 `routers` (📁 `app/routers/`)...
* &amp; ⚪️➡️ ⚫️, 🗄 🔁 `items` (📁 `app/routers/items.py`) &amp; `users` (📁 `app/routers/users.py`)...
🕹 `items` 🔜 ✔️ 🔢 `router` (`items.router`). 👉 🎏 1️⃣ 👥 ✍ 📁 `app/routers/items.py`, ⚫️ `APIRouter` 🎚.
&amp; ⤴️ 👥 🎏 🕹 `users`.
👥 💪 🗄 👫 💖:
```Python
from app.routers import items, users
```
!!! info
🥇 ⏬ "⚖ 🗄":
```Python
from .routers import items, users
```
🥈 ⏬ "🎆 🗄":
```Python
from app.routers import items, users
```
💡 🌅 🔃 🐍 📦 &amp; 🕹, ✍ <a href="https://docs.python.org/3/tutorial/modules.html" class="external-link" target="_blank">🛂 🐍 🧾 🔃 🕹</a>.
### ❎ 📛 💥
👥 🏭 🔁 `items` 🔗, ↩️ 🏭 🚮 🔢 `router`.
👉 ↩️ 👥 ✔️ ➕1️⃣ 🔢 📛 `router` 🔁 `users`.
🚥 👥 ✔️ 🗄 1️⃣ ⏮️ 🎏, 💖:
```Python
from .routers.items import router
from .routers.users import router
```
`router` ⚪️➡️ `users` 🔜 📁 1️⃣ ⚪️➡️ `items` &amp; 👥 🚫🔜 💪 ⚙️ 👫 🎏 🕰.
, 💪 ⚙️ 👯‍♂️ 👫 🎏 📁, 👥 🗄 🔁 🔗:
```Python hl_lines="4"
{!../../../docs_src/bigger_applications/app/main.py!}
```
### 🔌 `APIRouter``users` &amp; `items`
🔜, ➡️ 🔌 `router`Ⓜ ⚪️➡️ 🔁 `users` &amp; `items`:
```Python hl_lines="10-11"
{!../../../docs_src/bigger_applications/app/main.py!}
```
!!! info
`users.router` 🔌 `APIRouter` 🔘 📁 `app/routers/users.py`.
&amp; `items.router` 🔌 `APIRouter` 🔘 📁 `app/routers/items.py`.
⏮️ `app.include_router()` 👥 💪 🚮 🔠 `APIRouter` 👑 `FastAPI` 🈸.
⚫️ 🔜 🔌 🌐 🛣 ⚪️➡️ 👈 📻 🍕 ⚫️.
!!! note "📡 ℹ"
⚫️ 🔜 🤙 🔘 ✍ *➡ 🛠️* 🔠 *➡ 🛠️* 👈 📣 `APIRouter`.
, ⛅ 🎑, ⚫️ 🔜 🤙 👷 🚥 🌐 🎏 👁 📱.
!!! check
👆 🚫 ✔️ 😟 🔃 🎭 🕐❔ ✅ 📻.
👉 🔜 ✊ ⏲ &amp; 🔜 🕴 🔨 🕴.
⚫️ 🏆 🚫 📉 🎭. 👶
### 🔌 `APIRouter` ⏮️ 🛃 `prefix`, `tags`, `responses`, &amp; `dependencies`
🔜, ➡️ 🌈 👆 🏢 🤝 👆 `app/internal/admin.py` 📁.
⚫️ 🔌 `APIRouter` ⏮️ 📡 *➡ 🛠️* 👈 👆 🏢 💰 🖖 📚 🏗.
👉 🖼 ⚫️ 🔜 💎 🙅. ✋️ ➡️ 💬 👈 ↩️ ⚫️ 💰 ⏮️ 🎏 🏗 🏢, 👥 🚫🔜 🔀 ⚫️ &amp; 🚮 `prefix`, `dependencies`, `tags`, ♒️. 🔗 `APIRouter`:
```Python hl_lines="3"
{!../../../docs_src/bigger_applications/app/internal/admin.py!}
```
✋️ 👥 💚 ⚒ 🛃 `prefix` 🕐❔ ✅ `APIRouter` 👈 🌐 🚮 *➡ 🛠️* ▶️ ⏮️ `/admin`, 👥 💚 🔐 ⚫️ ⏮️ `dependencies` 👥 ⏪ ✔️ 👉 🏗, &amp; 👥 💚 🔌 `tags` &amp; `responses`.
👥 💪 📣 🌐 👈 🍵 ✔️ 🔀 ⏮️ `APIRouter` 🚶‍♀️ 👈 🔢 `app.include_router()`:
```Python hl_lines="14-17"
{!../../../docs_src/bigger_applications/app/main.py!}
```
👈 🌌, ⏮️ `APIRouter` 🔜 🚧 ⚗, 👥 💪 💰 👈 🎏 `app/internal/admin.py` 📁 ⏮️ 🎏 🏗 🏢.
🏁 👈 👆 📱, 🔠 *➡ 🛠️* ⚪️➡️ `admin` 🕹 🔜 ✔️:
* 🔡 `/admin`.
* 🔖 `admin`.
* 🔗 `get_token_header`.
* 📨 `418`. 👶
✋️ 👈 🔜 🕴 📉 👈 `APIRouter` 👆 📱, 🚫 🙆 🎏 📟 👈 ⚙️ ⚫️.
, 🖼, 🎏 🏗 💪 ⚙️ 🎏 `APIRouter` ⏮️ 🎏 🤝 👩‍🔬.
### 🔌 *➡ 🛠️*
👥 💪 🚮 *➡ 🛠️* 🔗 `FastAPI` 📱.
📥 👥 ⚫️... 🎦 👈 👥 💪 🤷:
```Python hl_lines="21-23"
{!../../../docs_src/bigger_applications/app/main.py!}
```
&amp; ⚫️ 🔜 👷 ☑, 👯‍♂️ ⏮️ 🌐 🎏 *➡ 🛠️* 🚮 ⏮️ `app.include_router()`.
!!! info "📶 📡 ℹ"
**🗒**: 👉 📶 📡 ℹ 👈 👆 🎲 💪 **🚶**.
---
`APIRouter`Ⓜ 🚫 "🗻", 👫 🚫 👽 ⚪️➡️ 🎂 🈸.
👉 ↩️ 👥 💚 🔌 👫 *➡ 🛠️* 🗄 🔗 &amp; 👩‍💻 🔢.
👥 🚫🔜 ❎ 👫 &amp; "🗻" 👫 ➡ 🎂, *➡ 🛠️* "🖖" (🏤-✍), 🚫 🔌 🔗.
## ✅ 🏧 🛠️ 🩺
🔜, 🏃 `uvicorn`, ⚙️ 🕹 `app.main` &amp; 🔢 `app`:
<div class="termy">
```console
$ uvicorn app.main:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
```
</div>
&amp; 📂 🩺 <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
👆 🔜 👀 🏧 🛠️ 🩺, ✅ ➡ ⚪️➡️ 🌐 🔁, ⚙️ ☑ ➡ (&amp; 🔡) &amp; ☑ 🔖:
<img src="/img/tutorial/bigger-applications/image01.png">
## 🔌 🎏 📻 💗 🕰 ⏮️ 🎏 `prefix`
👆 💪 ⚙️ `.include_router()` 💗 🕰 ⏮️ *🎏* 📻 ⚙️ 🎏 🔡.
👉 💪 ⚠, 🖼, 🎦 🎏 🛠️ 🔽 🎏 🔡, ✅ `/api/v1` &amp; `/api/latest`.
👉 🏧 ⚙️ 👈 👆 5️⃣📆 🚫 🤙 💪, ✋️ ⚫️ 📤 💼 👆.
## 🔌 `APIRouter` ➕1️⃣
🎏 🌌 👆 💪 🔌 `APIRouter` `FastAPI` 🈸, 👆 💪 🔌 `APIRouter` ➕1️⃣ `APIRouter` ⚙️:
```Python
router.include_router(other_router)
```
⚒ 💭 👆 ⚫️ ⏭ 🔌 `router` `FastAPI` 📱, 👈 *➡ 🛠️* ⚪️➡️ `other_router` 🔌.

68
docs/em/docs/tutorial/body-fields.md

@ -0,0 +1,68 @@
# 💪 - 🏑
🎏 🌌 👆 💪 📣 🌖 🔬 &amp; 🗃 *➡ 🛠️ 🔢* 🔢 ⏮️ `Query`, `Path` &amp; `Body`, 👆 💪 📣 🔬 &amp; 🗃 🔘 Pydantic 🏷 ⚙️ Pydantic `Field`.
## 🗄 `Field`
🥇, 👆 ✔️ 🗄 ⚫️:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="2"
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
!!! warning
👀 👈 `Field` 🗄 🔗 ⚪️➡️ `pydantic`, 🚫 ⚪️➡️ `fastapi` 🌐 🎂 (`Query`, `Path`, `Body`, ♒️).
## 📣 🏷 🔢
👆 💪 ⤴️ ⚙️ `Field` ⏮️ 🏷 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="11-14"
{!> ../../../docs_src/body_fields/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="9-12"
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
`Field` 👷 🎏 🌌 `Query`, `Path` &amp; `Body`, ⚫️ ✔️ 🌐 🎏 🔢, ♒️.
!!! note "📡 ℹ"
🤙, `Query`, `Path` &amp; 🎏 👆 🔜 👀 ⏭ ✍ 🎚 🏿 ⚠ `Param` 🎓, ❔ ⚫️ 🏿 Pydantic `FieldInfo` 🎓.
&amp; Pydantic `Field` 📨 👐 `FieldInfo` 👍.
`Body` 📨 🎚 🏿 `FieldInfo` 🔗. &amp; 📤 🎏 👆 🔜 👀 ⏪ 👈 🏿 `Body` 🎓.
💭 👈 🕐❔ 👆 🗄 `Query`, `Path`, &amp; 🎏 ⚪️➡️ `fastapi`, 👈 🤙 🔢 👈 📨 🎁 🎓.
!!! tip
👀 ❔ 🔠 🏷 🔢 ⏮️ 🆎, 🔢 💲 &amp; `Field` ✔️ 🎏 📊 *➡ 🛠️ 🔢* 🔢, ⏮️ `Field` ↩️ `Path`, `Query` &amp; `Body`.
## 🚮 ➕ ℹ
👆 💪 📣 ➕ ℹ `Field`, `Query`, `Body`, ♒️. &amp; ⚫️ 🔜 🔌 🏗 🎻 🔗.
👆 🔜 💡 🌅 🔃 ❎ ➕ ℹ ⏪ 🩺, 🕐❔ 🏫 📣 🖼.
!!! warning
➕ 🔑 🚶‍♀️ `Field` 🔜 🎁 📉 🗄 🔗 👆 🈸.
👫 🔑 5️⃣📆 🚫 🎯 🍕 🗄 🔧, 🗄 🧰, 🖼 [🗄 💳](https://validator.swagger.io/), 5️⃣📆 🚫 👷 ⏮️ 👆 🏗 🔗.
## 🌃
👆 💪 ⚙️ Pydantic `Field` 📣 ➕ 🔬 &amp; 🗃 🏷 🔢.
👆 💪 ⚙️ ➕ 🇨🇻 ❌ 🚶‍♀️ 🌖 🎻 🔗 🗃.

213
docs/em/docs/tutorial/body-multiple-params.md

@ -0,0 +1,213 @@
# 💪 - 💗 🔢
🔜 👈 👥 ✔️ 👀 ❔ ⚙️ `Path` &amp; `Query`, ➡️ 👀 🌅 🏧 ⚙️ 📨 💪 📄.
## 🌀 `Path`, `Query` &amp; 💪 🔢
🥇, ↗️, 👆 💪 🌀 `Path`, `Query` &amp; 📨 💪 🔢 📄 ➡ &amp; **FastAPI** 🔜 💭 ⚫️❔.
&amp; 👆 💪 📣 💪 🔢 📦, ⚒ 🔢 `None`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="17-19"
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
!!! note
👀 👈, 👉 💼, `item` 👈 🔜 ✊ ⚪️➡️ 💪 📦. ⚫️ ✔️ `None` 🔢 💲.
## 💗 💪 🔢
⏮️ 🖼, *➡ 🛠️* 🔜 ⌛ 🎻 💪 ⏮️ 🔢 `Item`, 💖:
```JSON
{
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
}
```
✋️ 👆 💪 📣 💗 💪 🔢, ✅ `item` &amp; `user`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
👉 💼, **FastAPI** 🔜 👀 👈 📤 🌅 🌘 1️⃣ 💪 🔢 🔢 (2️⃣ 🔢 👈 Pydantic 🏷).
, ⚫️ 🔜 ⤴️ ⚙️ 🔢 📛 🔑 (🏑 📛) 💪, &amp; ⌛ 💪 💖:
```JSON
{
"item": {
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
},
"user": {
"username": "dave",
"full_name": "Dave Grohl"
}
}
```
!!! note
👀 👈 ✋️ `item` 📣 🎏 🌌 ⏭, ⚫️ 🔜 ⌛ 🔘 💪 ⏮️ 🔑 `item`.
**FastAPI** 🔜 🏧 🛠️ ⚪️➡️ 📨, 👈 🔢 `item` 📨 ⚫️ 🎯 🎚 &amp; 🎏 `user`.
⚫️ 🔜 🎭 🔬 ⚗ 💽, &amp; 🔜 📄 ⚫️ 💖 👈 🗄 🔗 &amp; 🏧 🩺.
## ⭐ 💲 💪
🎏 🌌 📤 `Query` &amp; `Path` 🔬 ➕ 💽 🔢 &amp; ➡ 🔢, **FastAPI** 🚚 🌓 `Body`.
🖼, ↔ ⏮️ 🏷, 👆 💪 💭 👈 👆 💚 ✔️ ➕1️⃣ 🔑 `importance` 🎏 💪, 🥈 `item` &amp; `user`.
🚥 👆 📣 ⚫️, ↩️ ⚫️ ⭐ 💲, **FastAPI** 🔜 🤔 👈 ⚫️ 🔢 🔢.
✋️ 👆 💪 💡 **FastAPI** 😥 ⚫️ ➕1️⃣ 💪 🔑 ⚙️ `Body`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial003.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
```
👉 💼, **FastAPI** 🔜 ⌛ 💪 💖:
```JSON
{
"item": {
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
},
"user": {
"username": "dave",
"full_name": "Dave Grohl"
},
"importance": 5
}
```
🔄, ⚫️ 🔜 🗜 📊 🆎, ✔, 📄, ♒️.
## 💗 💪 = &amp; 🔢
↗️, 👆 💪 📣 🌖 🔢 🔢 🕐❔ 👆 💪, 🌖 🙆 💪 🔢.
, 🔢, ⭐ 💲 🔬 🔢 🔢, 👆 🚫 ✔️ 🎯 🚮 `Query`, 👆 💪:
```Python
q: Union[str, None] = None
```
⚖️ 🐍 3️⃣.1️⃣0️⃣ &amp; 🔛:
```Python
q: str | None = None
```
🖼:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="27"
{!> ../../../docs_src/body_multiple_params/tutorial004.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="26"
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
!!! info
`Body` ✔️ 🌐 🎏 ➕ 🔬 &amp; 🗃 🔢 `Query`,`Path` &amp; 🎏 👆 🔜 👀 ⏪.
## ⏯ 👁 💪 🔢
➡️ 💬 👆 🕴 ✔️ 👁 `item` 💪 🔢 ⚪️➡️ Pydantic 🏷 `Item`.
🔢, **FastAPI** 🔜 ⤴️ ⌛ 🚮 💪 🔗.
✋️ 🚥 👆 💚 ⚫️ ⌛ 🎻 ⏮️ 🔑 `item` &amp; 🔘 ⚫️ 🏷 🎚, ⚫️ 🔨 🕐❔ 👆 📣 ➕ 💪 🔢, 👆 💪 ⚙️ 🎁 `Body` 🔢 `embed`:
```Python
item: Item = Body(embed=True)
```
:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="17"
{!> ../../../docs_src/body_multiple_params/tutorial005.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="15"
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
👉 💼 **FastAPI** 🔜 ⌛ 💪 💖:
```JSON hl_lines="2"
{
"item": {
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
}
}
```
↩️:
```JSON
{
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2
}
```
## 🌃
👆 💪 🚮 💗 💪 🔢 👆 *➡ 🛠️ 🔢*, ✋️ 📨 💪 🕴 ✔️ 👁 💪.
✋️ **FastAPI** 🔜 🍵 ⚫️, 🤝 👆 ☑ 📊 👆 🔢, &amp;&amp; 📄 ☑ 🔗 *➡ 🛠️*.
👆 💪 📣 ⭐ 💲 📨 🍕 💪.
&amp; 👆 💪 💡 **FastAPI** ⏯ 💪 🔑 🕐❔ 📤 🕴 👁 🔢 📣.

382
docs/em/docs/tutorial/body-nested-models.md

@ -0,0 +1,382 @@
# 💪 - 🔁 🏷
⏮️ **FastAPI**, 👆 💪 🔬, ✔, 📄, &amp; ⚙️ 🎲 🙇 🐦 🏷 (👏 Pydantic).
## 📇 🏑
👆 💪 🔬 🔢 🏾. 🖼, 🐍 `list`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="12"
{!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
```
👉 🔜 ⚒ `tags` 📇, 👐 ⚫️ 🚫 📣 🆎 🔣 📇.
## 📇 🏑 ⏮️ 🆎 🔢
✋️ 🐍 ✔️ 🎯 🌌 📣 📇 ⏮️ 🔗 🆎, ⚖️ "🆎 🔢":
### 🗄 ⌨ `List`
🐍 3️⃣.9️⃣ &amp; 🔛 👆 💪 ⚙️ 🐩 `list` 📣 👫 🆎 ✍ 👥 🔜 👀 🔛. 👶
✋️ 🐍 ⏬ ⏭ 3️⃣.9️⃣ (3️⃣.6️⃣ &amp; 🔛), 👆 🥇 💪 🗄 `List` ⚪️➡️ 🐩 🐍 `typing` 🕹:
```Python hl_lines="1"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
```
### 📣 `list` ⏮️ 🆎 🔢
📣 🆎 👈 ✔️ 🆎 🔢 (🔗 🆎), 💖 `list`, `dict`, `tuple`:
* 🚥 👆 🐍 ⏬ 🔅 🌘 3️⃣.9️⃣, 🗄 👫 🌓 ⏬ ⚪️➡️ `typing` 🕹
* 🚶‍♀️ 🔗 🆎(Ⓜ) "🆎 🔢" ⚙️ ⬜ 🗜: `[` &amp; `]`
🐍 3️⃣.9️⃣ ⚫️ 🔜:
```Python
my_list: list[str]
```
⏬ 🐍 ⏭ 3️⃣.9️⃣, ⚫️ 🔜:
```Python
from typing import List
my_list: List[str]
```
👈 🌐 🐩 🐍 ❕ 🆎 📄.
⚙️ 👈 🎏 🐩 ❕ 🏷 🔢 ⏮️ 🔗 🆎.
, 👆 🖼, 👥 💪 ⚒ `tags` 🎯 "📇 🎻":
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="12"
{!> ../../../docs_src/body_nested_models/tutorial002_py310.py!}
```
## ⚒ 🆎
✋️ ⤴️ 👥 💭 🔃 ⚫️, &amp; 🤔 👈 🔖 🚫🔜 🚫 🔁, 👫 🔜 🎲 😍 🎻.
&amp; 🐍 ✔️ 🎁 💽 🆎 ⚒ 😍 🏬, `set`.
⤴️ 👥 💪 📣 `tags` ⚒ 🎻:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="1 14"
{!> ../../../docs_src/body_nested_models/tutorial003.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial003_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="12"
{!> ../../../docs_src/body_nested_models/tutorial003_py310.py!}
```
⏮️ 👉, 🚥 👆 📨 📨 ⏮️ ❎ 📊, ⚫️ 🔜 🗜 ⚒ 😍 🏬.
&amp; 🕐❔ 👆 🔢 👈 📊, 🚥 ℹ ✔️ ❎, ⚫️ 🔜 🔢 ⚒ 😍 🏬.
&amp; ⚫️ 🔜 ✍ / 📄 ➡️ 💁‍♂️.
## 🐦 🏷
🔠 🔢 Pydantic 🏷 ✔️ 🆎.
✋️ 👈 🆎 💪 ⚫️ ➕1️⃣ Pydantic 🏷.
, 👆 💪 📣 🙇 🐦 🎻 "🎚" ⏮️ 🎯 🔢 📛, 🆎 &amp; 🔬.
🌐 👈, 🎲 🐦.
### 🔬 📊
🖼, 👥 💪 🔬 `Image` 🏷:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="7-9"
{!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
```
### ⚙️ 📊 🆎
&amp; ⤴️ 👥 💪 ⚙️ ⚫️ 🆎 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="18"
{!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
```
👉 🔜 ⛓ 👈 **FastAPI** 🔜 ⌛ 💪 🎏:
```JSON
{
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2,
"tags": ["rock", "metal", "bar"],
"image": {
"url": "http://example.com/baz.jpg",
"name": "The Foo live"
}
}
```
🔄, 🤸 👈 📄, ⏮️ **FastAPI** 👆 🤚:
* 👨‍🎨 🐕‍🦺 (🛠️, ♒️), 🐦 🏷
* 💽 🛠️
* 💽 🔬
* 🏧 🧾
## 🎁 🆎 &amp; 🔬
↖️ ⚪️➡️ 😐 ⭐ 🆎 💖 `str`, `int`, `float`, ♒️. 👆 💪 ⚙️ 🌅 🏗 ⭐ 🆎 👈 😖 ⚪️➡️ `str`.
👀 🌐 🎛 👆 ✔️, 🛒 🩺 <a href="https://pydantic-docs.helpmanual.io/usage/types/" class="external-link" target="_blank">Pydantic 😍 🆎</a>. 👆 🔜 👀 🖼 ⏭ 📃.
🖼, `Image` 🏷 👥 ✔️ `url` 🏑, 👥 💪 📣 ⚫️ ↩️ `str`, Pydantic `HttpUrl`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="2 8"
{!> ../../../docs_src/body_nested_models/tutorial005_py310.py!}
```
🎻 🔜 ✅ ☑ 📛, &amp; 📄 🎻 🔗 / 🗄 ✅.
## 🔢 ⏮️ 📇 📊
👆 💪 ⚙️ Pydantic 🏷 🏾 `list`, `set`, ♒️:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="18"
{!> ../../../docs_src/body_nested_models/tutorial006_py310.py!}
```
👉 🔜 ⌛ (🗜, ✔, 📄, ♒️) 🎻 💪 💖:
```JSON hl_lines="11"
{
"name": "Foo",
"description": "The pretender",
"price": 42.0,
"tax": 3.2,
"tags": [
"rock",
"metal",
"bar"
],
"images": [
{
"url": "http://example.com/baz.jpg",
"name": "The Foo live"
},
{
"url": "http://example.com/dave.jpg",
"name": "The Baz"
}
]
}
```
!!! info
👀 ❔ `images` 🔑 🔜 ✔️ 📇 🖼 🎚.
## 🙇 🐦 🏷
👆 💪 🔬 🎲 🙇 🐦 🏷:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="7 12 18 21 25"
{!> ../../../docs_src/body_nested_models/tutorial007_py310.py!}
```
!!! info
👀 ❔ `Offer` ✔️ 📇 `Item`Ⓜ, ❔ 🔄 ✔️ 📦 📇 `Image`
## 💪 😁 📇
🚥 🔝 🎚 💲 🎻 💪 👆 ⌛ 🎻 `array` (🐍 `list`), 👆 💪 📣 🆎 🔢 🔢, 🎏 Pydantic 🏷:
```Python
images: List[Image]
```
⚖️ 🐍 3️⃣.9️⃣ &amp; 🔛:
```Python
images: list[Image]
```
:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="15"
{!> ../../../docs_src/body_nested_models/tutorial008.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="13"
{!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
```
## 👨‍🎨 🐕‍🦺 🌐
&amp; 👆 🤚 👨‍🎨 🐕‍🦺 🌐.
🏬 🔘 📇:
<img src="/img/tutorial/body-nested-models/image01.png">
👆 🚫 🚫 🤚 👉 😇 👨‍🎨 🐕‍🦺 🚥 👆 👷 🔗 ⏮️ `dict` ↩️ Pydantic 🏷.
✋️ 👆 🚫 ✔️ 😟 🔃 👫 👯‍♂️, 📨 #️⃣ 🗜 🔁 &amp; 👆 🔢 🗜 🔁 🎻 💁‍♂️.
## 💪 ❌ `dict`
👆 💪 📣 💪 `dict` ⏮️ 🔑 🆎 &amp; 💲 🎏 🆎.
🍵 ✔️ 💭 ⏪ ⚫️❔ ☑ 🏑/🔢 📛 (🔜 💼 ⏮️ Pydantic 🏷).
👉 🔜 ⚠ 🚥 👆 💚 📨 🔑 👈 👆 🚫 ⏪ 💭.
---
🎏 ⚠ 💼 🕐❔ 👆 💚 ✔️ 🔑 🎏 🆎, ✅ `int`.
👈 ⚫️❔ 👥 🔜 👀 📥.
👉 💼, 👆 🔜 🚫 🙆 `dict` 📏 ⚫️ ✔️ `int` 🔑 ⏮️ `float` 💲:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9"
{!> ../../../docs_src/body_nested_models/tutorial009.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="7"
{!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
```
!!! tip
✔️ 🤯 👈 🎻 🕴 🐕‍🦺 `str` 🔑.
✋️ Pydantic ✔️ 🏧 💽 🛠️.
👉 ⛓ 👈, ✋️ 👆 🛠️ 👩‍💻 💪 🕴 📨 🎻 🔑, 📏 👈 🎻 🔌 😁 🔢, Pydantic 🔜 🗜 👫 &amp; ✔ 👫.
&amp; `dict` 👆 📨 `weights` 🔜 🤙 ✔️ `int` 🔑 &amp; `float` 💲.
## 🌃
⏮️ **FastAPI** 👆 ✔️ 🔆 💪 🚚 Pydantic 🏷, ⏪ 🚧 👆 📟 🙅, 📏 &amp; 😍.
✋️ ⏮️ 🌐 💰:
* 👨‍🎨 🐕‍🦺 (🛠️ 🌐 ❗)
* 💽 🛠️ (.Ⓜ.. ✍ / 🛠️)
* 💽 🔬
* 🔗 🧾
* 🏧 🩺

155
docs/em/docs/tutorial/body-updates.md

@ -0,0 +1,155 @@
# 💪 - ℹ
## ℹ ❎ ⏮️ `PUT`
ℹ 🏬 👆 💪 ⚙️ <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT" class="external-link" target="_blank">🇺🇸🔍 `PUT`</a> 🛠️.
👆 💪 ⚙️ `jsonable_encoder` 🗜 🔢 💽 📊 👈 💪 🏪 🎻 (✅ ⏮️ ☁ 💽). 🖼, 🏭 `datetime` `str`.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="30-35"
{!> ../../../docs_src/body_updates/tutorial001.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="30-35"
{!> ../../../docs_src/body_updates/tutorial001_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="28-33"
{!> ../../../docs_src/body_updates/tutorial001_py310.py!}
```
`PUT` ⚙️ 📨 💽 👈 🔜 ❎ ♻ 💽.
### ⚠ 🔃 ❎
👈 ⛓ 👈 🚥 👆 💚 ℹ 🏬 `bar` ⚙️ `PUT` ⏮️ 💪 ⚗:
```Python
{
"name": "Barz",
"price": 3,
"description": None,
}
```
↩️ ⚫️ 🚫 🔌 ⏪ 🏪 🔢 `"tax": 20.2`, 🔢 🏷 🔜 ✊ 🔢 💲 `"tax": 10.5`.
&amp; 📊 🔜 🖊 ⏮️ 👈 "🆕" `tax` `10.5`.
## 🍕 ℹ ⏮️ `PATCH`
👆 💪 ⚙️ <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH" class="external-link" target="_blank">🇺🇸🔍 `PATCH`</a> 🛠️ *🍕* ℹ 💽.
👉 ⛓ 👈 👆 💪 📨 🕴 💽 👈 👆 💚 ℹ, 🍂 🎂 🐣.
!!! Note
`PATCH` 🌘 🛎 ⚙️ &amp; 💭 🌘 `PUT`.
&amp; 📚 🏉 ⚙️ 🕴 `PUT`, 🍕 ℹ.
👆 **🆓** ⚙️ 👫 👐 👆 💚, **FastAPI** 🚫 🚫 🙆 🚫.
✋️ 👉 🦮 🎦 👆, 🌖 ⚖️ 🌘, ❔ 👫 🎯 ⚙️.
### ⚙️ Pydantic `exclude_unset` 🔢
🚥 👆 💚 📨 🍕 ℹ, ⚫️ 📶 ⚠ ⚙️ 🔢 `exclude_unset` Pydantic 🏷 `.dict()`.
💖 `item.dict(exclude_unset=True)`.
👈 🔜 🏗 `dict` ⏮️ 🕴 💽 👈 ⚒ 🕐❔ 🏗 `item` 🏷, 🚫 🔢 💲.
⤴️ 👆 💪 ⚙️ 👉 🏗 `dict` ⏮️ 🕴 💽 👈 ⚒ (📨 📨), 🚫 🔢 💲:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="34"
{!> ../../../docs_src/body_updates/tutorial002.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="34"
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="32"
{!> ../../../docs_src/body_updates/tutorial002_py310.py!}
```
### ⚙️ Pydantic `update` 🔢
🔜, 👆 💪 ✍ 📁 ♻ 🏷 ⚙️ `.copy()`, &amp; 🚶‍♀️ `update` 🔢 ⏮️ `dict` ⚗ 💽 ℹ.
💖 `stored_item_model.copy(update=update_data)`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="35"
{!> ../../../docs_src/body_updates/tutorial002.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="35"
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="33"
{!> ../../../docs_src/body_updates/tutorial002_py310.py!}
```
### 🍕 ℹ 🌃
📄, ✔ 🍕 ℹ 👆 🔜:
* (⚗) ⚙️ `PATCH` ↩️ `PUT`.
* 🗃 🏪 💽.
* 🚮 👈 💽 Pydantic 🏷.
* 🏗 `dict` 🍵 🔢 💲 ⚪️➡️ 🔢 🏷 (⚙️ `exclude_unset`).
* 👉 🌌 👆 💪 ℹ 🕴 💲 🤙 ⚒ 👩‍💻, ↩️ 🔐 💲 ⏪ 🏪 ⏮️ 🔢 💲 👆 🏷.
* ✍ 📁 🏪 🏷, 🛠️ ⚫️ 🔢 ⏮️ 📨 🍕 ℹ (⚙️ `update` 🔢).
* 🗜 📁 🏷 🕳 👈 💪 🏪 👆 💽 (🖼, ⚙️ `jsonable_encoder`).
* 👉 ⭐ ⚙️ 🏷 `.dict()` 👩‍🔬 🔄, ✋️ ⚫️ ⚒ 💭 (&amp; 🗜) 💲 💽 🆎 👈 💪 🗜 🎻, 🖼, `datetime` `str`.
* 🖊 💽 👆 💽.
* 📨 ℹ 🏷.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="30-37"
{!> ../../../docs_src/body_updates/tutorial002.py!}
```
=== "🐍 3️⃣.9️⃣ &amp; 🔛"
```Python hl_lines="30-37"
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="28-35"
{!> ../../../docs_src/body_updates/tutorial002_py310.py!}
```
!!! tip
👆 💪 🤙 ⚙️ 👉 🎏 ⚒ ⏮️ 🇺🇸🔍 `PUT` 🛠️.
✋️ 🖼 📥 ⚙️ `PATCH` ↩️ ⚫️ ✍ 👫 ⚙️ 💼.
!!! note
👀 👈 🔢 🏷 ✔.
, 🚥 👆 💚 📨 🍕 ℹ 👈 💪 🚫 🌐 🔢, 👆 💪 ✔️ 🏷 ⏮️ 🌐 🔢 ™ 📦 (⏮️ 🔢 💲 ⚖️ `None`).
🔬 ⚪️➡️ 🏷 ⏮️ 🌐 📦 💲 **ℹ** &amp; 🏷 ⏮️ ✔ 💲 **🏗**, 👆 💪 ⚙️ 💭 🔬 [➕ 🏷](extra-models.md){.internal-link target=_blank}.

213
docs/em/docs/tutorial/body.md

@ -0,0 +1,213 @@
# 📨 💪
🕐❔ 👆 💪 📨 📊 ⚪️➡️ 👩‍💻 (➡️ 💬, 🖥) 👆 🛠️, 👆 📨 ⚫️ **📨 💪**.
**📨** 💪 📊 📨 👩‍💻 👆 🛠️. **📨** 💪 💽 👆 🛠️ 📨 👩‍💻.
👆 🛠️ 🌖 🕧 ✔️ 📨 **📨** 💪. ✋️ 👩‍💻 🚫 🎯 💪 📨 **📨** 💪 🌐 🕰.
📣 **📨** 💪, 👆 ⚙️ <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> 🏷 ⏮️ 🌐 👫 🏋️ &amp; 💰.
!!! info
📨 💽, 👆 🔜 ⚙️ 1️⃣: `POST` (🌅 ⚠), `PUT`, `DELETE` ⚖️ `PATCH`.
📨 💪 ⏮️ `GET` 📨 ✔️ ⚠ 🎭 🔧, 👐, ⚫️ 🐕‍🦺 FastAPI, 🕴 📶 🏗/😕 ⚙️ 💼.
⚫️ 🚫, 🎓 🩺 ⏮️ 🦁 🎚 🏆 🚫 🎦 🧾 💪 🕐❔ ⚙️ `GET`, &amp; 🗳 🖕 💪 🚫 🐕‍🦺 ⚫️.
## 🗄 Pydantic `BaseModel`
🥇, 👆 💪 🗄 `BaseModel` ⚪️➡️ `pydantic`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="4"
{!> ../../../docs_src/body/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="2"
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
## ✍ 👆 💽 🏷
⤴️ 👆 📣 👆 💽 🏷 🎓 👈 😖 ⚪️➡️ `BaseModel`.
⚙️ 🐩 🐍 🆎 🌐 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="7-11"
{!> ../../../docs_src/body/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="5-9"
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
🎏 🕐❔ 📣 🔢 🔢, 🕐❔ 🏷 🔢 ✔️ 🔢 💲, ⚫️ 🚫 ✔. ⏪, ⚫️ ✔. ⚙️ `None` ⚒ ⚫️ 📦.
🖼, 👉 🏷 🔛 📣 🎻 "`object`" (⚖️ 🐍 `dict`) 💖:
```JSON
{
"name": "Foo",
"description": "An optional description",
"price": 45.2,
"tax": 3.5
}
```
... `description` &amp; `tax` 📦 (⏮️ 🔢 💲 `None`), 👉 🎻 "`object`" 🔜 ☑:
```JSON
{
"name": "Foo",
"price": 45.2
}
```
## 📣 ⚫️ 🔢
🚮 ⚫️ 👆 *➡ 🛠️*, 📣 ⚫️ 🎏 🌌 👆 📣 ➡ &amp; 🔢 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="16"
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
...&amp; 📣 🚮 🆎 🏷 👆 ✍, `Item`.
## 🏁
⏮️ 👈 🐍 🆎 📄, **FastAPI** 🔜:
* ✍ 💪 📨 🎻.
* 🗜 🔗 🆎 (🚥 💪).
* ✔ 💽.
* 🚥 💽 ❌, ⚫️ 🔜 📨 👌 &amp; 🆑 ❌, ☠️ ⚫️❔ 🌐❔ &amp; ⚫️❔ ❌ 📊.
* 🤝 👆 📨 📊 🔢 `item`.
* 👆 📣 ⚫️ 🔢 🆎 `Item`, 👆 🔜 ✔️ 🌐 👨‍🎨 🐕‍🦺 (🛠️, ♒️) 🌐 🔢 &amp; 👫 🆎.
* 🏗 <a href="https://json-schema.org" class="external-link" target="_blank">🎻 🔗</a> 🔑 👆 🏷, 👆 💪 ⚙️ 👫 🙆 🙆 👆 💖 🚥 ⚫️ ⚒ 🔑 👆 🏗.
* 👈 🔗 🔜 🍕 🏗 🗄 🔗, &amp; ⚙️ 🏧 🧾 <abbr title="User Interfaces"></abbr>.
## 🏧 🩺
🎻 🔗 👆 🏷 🔜 🍕 👆 🗄 🏗 🔗, &amp; 🔜 🎦 🎓 🛠️ 🩺:
<img src="/img/tutorial/body/image01.png">
&amp; 🔜 ⚙️ 🛠️ 🩺 🔘 🔠 *➡ 🛠️* 👈 💪 👫:
<img src="/img/tutorial/body/image02.png">
## 👨‍🎨 🐕‍🦺
👆 👨‍🎨, 🔘 👆 🔢 👆 🔜 🤚 🆎 🔑 &amp; 🛠️ 🌐 (👉 🚫🔜 🔨 🚥 👆 📨 `dict` ↩️ Pydantic 🏷):
<img src="/img/tutorial/body/image03.png">
👆 🤚 ❌ ✅ ❌ 🆎 🛠️:
<img src="/img/tutorial/body/image04.png">
👉 🚫 🤞, 🎂 🛠️ 🏗 🤭 👈 🔧.
&amp; ⚫️ 🙇 💯 🔧 🌓, ⏭ 🙆 🛠️, 🚚 ⚫️ 🔜 👷 ⏮️ 🌐 👨‍🎨.
📤 🔀 Pydantic ⚫️ 🐕‍🦺 👉.
⏮️ 🖼 ✊ ⏮️ <a href="https://code.visualstudio.com" class="external-link" target="_blank">🎙 🎙 📟</a>.
✋️ 👆 🔜 🤚 🎏 👨‍🎨 🐕‍🦺 ⏮️ <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">🗒</a> &amp; 🌅 🎏 🐍 👨‍🎨:
<img src="/img/tutorial/body/image05.png">
!!! tip
🚥 👆 ⚙️ <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">🗒</a> 👆 👨‍🎨, 👆 💪 ⚙️ <a href="https://github.com/koxudaxi/pydantic-pycharm-plugin/" class="external-link" target="_blank">Pydantic 🗒 📁</a>.
⚫️ 📉 👨‍🎨 🐕‍🦺 Pydantic 🏷, ⏮️:
* 🚘-🛠️
* 🆎 ✅
* 🛠️
* 🔎
* 🔬
## ⚙️ 🏷
🔘 🔢, 👆 💪 🔐 🌐 🔢 🏷 🎚 🔗:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="21"
{!> ../../../docs_src/body/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="19"
{!> ../../../docs_src/body/tutorial002_py310.py!}
```
## 📨 💪 ➕ ➡ 🔢
👆 💪 📣 ➡ 🔢 &amp; 📨 💪 🎏 🕰.
**FastAPI** 🔜 🤔 👈 🔢 🔢 👈 🏏 ➡ 🔢 🔜 **✊ ⚪️➡️ ➡**, &amp; 👈 🔢 🔢 👈 📣 Pydantic 🏷 🔜 **✊ ⚪️➡️ 📨 💪**.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="17-18"
{!> ../../../docs_src/body/tutorial003.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="15-16"
{!> ../../../docs_src/body/tutorial003_py310.py!}
```
## 📨 💪 ➕ ➡ ➕ 🔢 🔢
👆 💪 📣 **💪**, **➡** &amp; **🔢** 🔢, 🌐 🎏 🕰.
**FastAPI** 🔜 🤔 🔠 👫 &amp; ✊ 📊 ⚪️➡️ ☑ 🥉.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial004.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="16"
{!> ../../../docs_src/body/tutorial004_py310.py!}
```
🔢 🔢 🔜 🤔 ⏩:
* 🚥 🔢 📣 **➡**, ⚫️ 🔜 ⚙️ ➡ 🔢.
* 🚥 🔢 **⭐ 🆎** (💖 `int`, `float`, `str`, `bool`, ♒️) ⚫️ 🔜 🔬 **🔢** 🔢.
* 🚥 🔢 📣 🆎 **Pydantic 🏷**, ⚫️ 🔜 🔬 📨 **💪**.
!!! note
FastAPI 🔜 💭 👈 💲 `q` 🚫 ✔ ↩️ 🔢 💲 `= None`.
`Union` `Union[str, None]` 🚫 ⚙️ FastAPI, ✋️ 🔜 ✔ 👆 👨‍🎨 🤝 👆 👍 🐕‍🦺 &amp; 🔍 ❌.
## 🍵 Pydantic
🚥 👆 🚫 💚 ⚙️ Pydantic 🏷, 👆 💪 ⚙️ **💪** 🔢. 👀 🩺 [💪 - 💗 🔢: ⭐ 💲 💪](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}.

49
docs/em/docs/tutorial/cookie-params.md

@ -0,0 +1,49 @@
# 🍪 🔢
👆 💪 🔬 🍪 🔢 🎏 🌌 👆 🔬 `Query` &amp; `Path` 🔢.
## 🗄 `Cookie`
🥇 🗄 `Cookie`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="1"
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
## 📣 `Cookie` 🔢
⤴️ 📣 🍪 🔢 ⚙️ 🎏 📊 ⏮️ `Path` &amp; `Query`.
🥇 💲 🔢 💲, 👆 💪 🚶‍♀️ 🌐 ➕ 🔬 ⚖️ ✍ 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9"
{!> ../../../docs_src/cookie_params/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="7"
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
!!! note "📡 ℹ"
`Cookie` "👭" 🎓 `Path` &amp; `Query`. ⚫️ 😖 ⚪️➡️ 🎏 ⚠ `Param` 🎓.
✋️ 💭 👈 🕐❔ 👆 🗄 `Query`, `Path`, `Cookie` &amp; 🎏 ⚪️➡️ `fastapi`, 👈 🤙 🔢 👈 📨 🎁 🎓.
!!! info
📣 🍪, 👆 💪 ⚙️ `Cookie`, ↩️ ⏪ 🔢 🔜 🔬 🔢 🔢.
## 🌃
📣 🍪 ⏮️ `Cookie`, ⚙️ 🎏 ⚠ ⚓ `Query` &amp; `Path`.

84
docs/em/docs/tutorial/cors.md

@ -0,0 +1,84 @@
# ⚜ (✖️-🇨🇳 ℹ 🤝)
<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" class="external-link" target="_blank">⚜ ⚖️ "✖️-🇨🇳 ℹ 🤝"</a> 🔗 ⚠ 🕐❔ 🕸 🏃‍♂ 🖥 ✔️ 🕸 📟 👈 🔗 ⏮️ 👩‍💻, &amp; 👩‍💻 🎏 "🇨🇳" 🌘 🕸.
## 🇨🇳
🇨🇳 🌀 🛠️ (`http`, `https`), 🆔 (`myapp.com`, `localhost`, `localhost.tiangolo.com`), &amp; ⛴ (`80`, `443`, `8080`).
, 🌐 👫 🎏 🇨🇳:
* `http://localhost`
* `https://localhost`
* `http://localhost:8080`
🚥 👫 🌐 `localhost`, 👫 ⚙️ 🎏 🛠️ ⚖️ ⛴,, 👫 🎏 "🇨🇳".
## 🔁
, ➡️ 💬 👆 ✔️ 🕸 🏃 👆 🖥 `http://localhost:8080`, &amp; 🚮 🕸 🔄 🔗 ⏮️ 👩‍💻 🏃 `http://localhost` (↩️ 👥 🚫 ✔ ⛴, 🖥 🔜 🤔 🔢 ⛴ `80`).
⤴️, 🖥 🔜 📨 🇺🇸🔍 `OPTIONS` 📨 👩‍💻, &amp; 🚥 👩‍💻 📨 ☑ 🎚 ✔ 📻 ⚪️➡️ 👉 🎏 🇨🇳 (`http://localhost:8080`) ⤴️ 🖥 🔜 ➡️ 🕸 🕸 📨 🚮 📨 👩‍💻.
🏆 👉, 👩‍💻 🔜 ✔️ 📇 "✔ 🇨🇳".
👉 💼, ⚫️ 🔜 ✔️ 🔌 `http://localhost:8080` 🕸 👷 ☑.
## 🃏
⚫️ 💪 📣 📇 `"*"` ("🃏") 💬 👈 🌐 ✔.
✋️ 👈 🔜 🕴 ✔ 🎯 🆎 📻, 🚫 🌐 👈 🔌 🎓: 🍪, ✔ 🎚 💖 📚 ⚙️ ⏮️ 📨 🤝, ♒️.
, 🌐 👷 ☑, ⚫️ 👻 ✔ 🎯 ✔ 🇨🇳.
## ⚙️ `CORSMiddleware`
👆 💪 🔗 ⚫️ 👆 **FastAPI** 🈸 ⚙️ `CORSMiddleware`.
* 🗄 `CORSMiddleware`.
* ✍ 📇 ✔ 🇨🇳 (🎻).
* 🚮 ⚫️ "🛠️" 👆 **FastAPI** 🈸.
👆 💪 ✔ 🚥 👆 👩‍💻 ✔:
* 🎓 (✔ 🎚, 🍪, ♒️).
* 🎯 🇺🇸🔍 👩‍🔬 (`POST`, `PUT`) ⚖️ 🌐 👫 ⏮️ 🃏 `"*"`.
* 🎯 🇺🇸🔍 🎚 ⚖️ 🌐 👫 ⏮️ 🃏 `"*"`.
```Python hl_lines="2 6-11 13-19"
{!../../../docs_src/cors/tutorial001.py!}
```
🔢 🔢 ⚙️ `CORSMiddleware` 🛠️ 🚫 🔢, 👆 🔜 💪 🎯 🛠️ 🎯 🇨🇳, 👩‍🔬, ⚖️ 🎚, ✔ 🖥 ✔ ⚙️ 👫 ✖️-🆔 🔑.
📄 ❌ 🐕‍🦺:
* `allow_origins` - 📇 🇨🇳 👈 🔜 ✔ ⚒ ✖️-🇨🇳 📨. 🤶 Ⓜ. `['https://example.org', 'https://www.example.org']`. 👆 💪 ⚙️ `['*']` ✔ 🙆 🇨🇳.
* `allow_origin_regex` - 🎻 🎻 🏏 🛡 🇨🇳 👈 🔜 ✔ ⚒ ✖️-🇨🇳 📨. ✅ `'https://.*\.example\.org'`.
* `allow_methods` - 📇 🇺🇸🔍 👩‍🔬 👈 🔜 ✔ ✖️-🇨🇳 📨. 🔢 `['GET']`. 👆 💪 ⚙️ `['*']` ✔ 🌐 🐩 👩‍🔬.
* `allow_headers` - 📇 🇺🇸🔍 📨 🎚 👈 🔜 🐕‍🦺 ✖️-🇨🇳 📨. 🔢 `[]`. 👆 💪 ⚙️ `['*']` ✔ 🌐 🎚. `Accept`, `Accept-Language`, `Content-Language` &amp; `Content-Type` 🎚 🕧 ✔ <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests" class="external-link" rel="noopener" target="_blank">🙅 ⚜ 📨</a>.
* `allow_credentials` - 🎦 👈 🍪 🔜 🐕‍🦺 ✖️-🇨🇳 📨. 🔢 `False`. , `allow_origins` 🚫🔜 ⚒ `['*']` 🎓 ✔, 🇨🇳 🔜 ✔.
* `expose_headers` - 🎦 🙆 📨 🎚 👈 🔜 ⚒ ♿ 🖥. 🔢 `[]`.
* `max_age` - ⚒ 🔆 🕰 🥈 🖥 💾 ⚜ 📨. 🔢 `600`.
🛠️ 📨 2️⃣ 🎯 🆎 🇺🇸🔍 📨...
### ⚜ 🛫 📨
👉 🙆 `OPTIONS` 📨 ⏮️ `Origin` &amp; `Access-Control-Request-Method` 🎚.
👉 💼 🛠️ 🔜 🆘 📨 📨 &amp; 📨 ⏮️ ☑ ⚜ 🎚, &amp; 👯‍♂️ `200` ⚖️ `400` 📨 🎓 🎯.
### 🙅 📨
🙆 📨 ⏮️ `Origin` 🎚. 👉 💼 🛠️ 🔜 🚶‍♀️ 📨 🔘 😐, ✋️ 🔜 🔌 ☑ ⚜ 🎚 🔛 📨.
## 🌅 ℹ
🌖 ℹ 🔃 <abbr title="Cross-Origin Resource Sharing"></abbr>, ✅ <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" class="external-link" target="_blank">🦎 ⚜ 🧾</a>.
!!! note "📡 ℹ"
👆 💪 ⚙️ `from starlette.middleware.cors import CORSMiddleware`.
**FastAPI** 🚚 📚 🛠️ `fastapi.middleware` 🏪 👆, 👩‍💻. ✋️ 🌅 💪 🛠️ 👟 🔗 ⚪️➡️ 💃.

112
docs/em/docs/tutorial/debugging.md

@ -0,0 +1,112 @@
# 🛠️
👆 💪 🔗 🕹 👆 👨‍🎨, 🖼 ⏮️ 🎙 🎙 📟 ⚖️ 🗒.
## 🤙 `uvicorn`
👆 FastAPI 🈸, 🗄 &amp; 🏃 `uvicorn` 🔗:
```Python hl_lines="1 15"
{!../../../docs_src/debugging/tutorial001.py!}
```
### 🔃 `__name__ == "__main__"`
👑 🎯 `__name__ == "__main__"` ✔️ 📟 👈 🛠️ 🕐❔ 👆 📁 🤙 ⏮️:
<div class="termy">
```console
$ python myapp.py
```
</div>
✋️ 🚫 🤙 🕐❔ ➕1️⃣ 📁 🗄 ⚫️, 💖:
```Python
from myapp import app
```
#### 🌅 ℹ
➡️ 💬 👆 📁 🌟 `myapp.py`.
🚥 👆 🏃 ⚫️ ⏮️:
<div class="termy">
```console
$ python myapp.py
```
</div>
⤴️ 🔗 🔢 `__name__` 👆 📁, ✍ 🔁 🐍, 🔜 ✔️ 💲 🎻 `"__main__"`.
, 📄:
```Python
uvicorn.run(app, host="0.0.0.0", port=8000)
```
🔜 🏃.
---
👉 🏆 🚫 🔨 🚥 👆 🗄 👈 🕹 (📁).
, 🚥 👆 ✔️ ➕1️⃣ 📁 `importer.py` ⏮️:
```Python
from myapp import app
# Some more code
```
👈 💼, 🏧 🔢 🔘 `myapp.py` 🔜 🚫 ✔️ 🔢 `__name__` ⏮️ 💲 `"__main__"`.
, ⏸:
```Python
uvicorn.run(app, host="0.0.0.0", port=8000)
```
🔜 🚫 🛠️.
!!! info
🌅 ℹ, ✅ <a href="https://docs.python.org/3/library/__main__.html" class="external-link" target="_blank">🛂 🐍 🩺</a>.
## 🏃 👆 📟 ⏮️ 👆 🕹
↩️ 👆 🏃 Uvicorn 💽 🔗 ⚪️➡️ 👆 📟, 👆 💪 🤙 👆 🐍 📋 (👆 FastAPI 🈸) 🔗 ⚪️➡️ 🕹.
---
🖼, 🎙 🎙 📟, 👆 💪:
* 🚶 "ℹ" 🎛.
* "🚮 📳...".
* 🖊 "🐍"
* 🏃 🕹 ⏮️ 🎛 "`Python: Current File (Integrated Terminal)`".
⚫️ 🔜 ⤴️ ▶️ 💽 ⏮️ 👆 **FastAPI** 📟, ⛔️ 👆 0️⃣, ♒️.
📥 ❔ ⚫️ 💪 👀:
<img src="/img/tutorial/debugging/image01.png">
---
🚥 👆 ⚙️ 🗒, 👆 💪:
* 📂 "🏃" 🍣.
* 🖊 🎛 "ℹ...".
* ⤴️ 🔑 🍣 🎦 🆙.
* 🖊 📁 ℹ (👉 💼, `main.py`).
⚫️ 🔜 ⤴️ ▶️ 💽 ⏮️ 👆 **FastAPI** 📟, ⛔️ 👆 0️⃣, ♒️.
📥 ❔ ⚫️ 💪 👀:
<img src="/img/tutorial/debugging/image02.png">

247
docs/em/docs/tutorial/dependencies/classes-as-dependencies.md

@ -0,0 +1,247 @@
# 🎓 🔗
⏭ 🤿 ⏬ 🔘 **🔗 💉** ⚙️, ➡️ ♻ ⏮️ 🖼.
## `dict` ⚪️➡️ ⏮️ 🖼
⏮️ 🖼, 👥 🛬 `dict` ⚪️➡️ 👆 🔗 ("☑"):
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9"
{!> ../../../docs_src/dependencies/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="7"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
✋️ ⤴️ 👥 🤚 `dict` 🔢 `commons` *➡ 🛠️ 🔢*.
&amp; 👥 💭 👈 👨‍🎨 💪 🚫 🚚 📚 🐕‍🦺 (💖 🛠️) `dict`Ⓜ, ↩️ 👫 💪 🚫 💭 👫 🔑 &amp; 💲 🆎.
👥 💪 👍...
## ⚫️❔ ⚒ 🔗
🆙 🔜 👆 ✔️ 👀 🔗 📣 🔢.
✋️ 👈 🚫 🕴 🌌 📣 🔗 (👐 ⚫️ 🔜 🎲 🌖 ⚠).
🔑 ⚖ 👈 🔗 🔜 "🇧🇲".
"**🇧🇲**" 🐍 🕳 👈 🐍 💪 "🤙" 💖 🔢.
, 🚥 👆 ✔️ 🎚 `something` (👈 💪 _🚫_ 🔢) &amp; 👆 💪 "🤙" ⚫️ (🛠️ ⚫️) 💖:
```Python
something()
```
⚖️
```Python
something(some_argument, some_keyword_argument="foo")
```
⤴️ ⚫️ "🇧🇲".
## 🎓 🔗
👆 5️⃣📆 👀 👈 ✍ 👐 🐍 🎓, 👆 ⚙️ 👈 🎏 ❕.
🖼:
```Python
class Cat:
def __init__(self, name: str):
self.name = name
fluffy = Cat(name="Mr Fluffy")
```
👉 💼, `fluffy` 👐 🎓 `Cat`.
&amp;`fluffy`, 👆 "🤙" `Cat`.
, 🐍 🎓 **🇧🇲**.
⤴️, **FastAPI**, 👆 💪 ⚙️ 🐍 🎓 🔗.
⚫️❔ FastAPI 🤙 ✅ 👈 ⚫️ "🇧🇲" (🔢, 🎓 ⚖️ 🕳 🙆) &amp; 🔢 🔬.
🚥 👆 🚶‍♀️ "🇧🇲" 🔗 **FastAPI**, ⚫️ 🔜 🔬 🔢 👈 "🇧🇲", &amp; 🛠️ 👫 🎏 🌌 🔢 *➡ 🛠️ 🔢*. ✅ 🎧-🔗.
👈 ✔ 🇧🇲 ⏮️ 🙅‍♂ 🔢 🌐. 🎏 ⚫️ 🔜 *➡ 🛠️ 🔢* ⏮️ 🙅‍♂ 🔢.
⤴️, 👥 💪 🔀 🔗 "☑" `common_parameters` ⚪️➡️ 🔛 🎓 `CommonQueryParams`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="11-15"
{!> ../../../docs_src/dependencies/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="9-13"
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
💸 🙋 `__init__` 👩‍🔬 ⚙️ ✍ 👐 🎓:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="10"
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
...⚫️ ✔️ 🎏 🔢 👆 ⏮️ `common_parameters`:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="9"
{!> ../../../docs_src/dependencies/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="6"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
📚 🔢 ⚫️❔ **FastAPI** 🔜 ⚙️ "❎" 🔗.
👯‍♂️ 💼, ⚫️ 🔜 ✔️:
* 📦 `q` 🔢 🔢 👈 `str`.
* `skip` 🔢 🔢 👈 `int`, ⏮️ 🔢 `0`.
* `limit` 🔢 🔢 👈 `int`, ⏮️ 🔢 `100`.
👯‍♂️ 💼 💽 🔜 🗜, ✔, 📄 🔛 🗄 🔗, ♒️.
## ⚙️ ⚫️
🔜 👆 💪 📣 👆 🔗 ⚙️ 👉 🎓.
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial002.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
**FastAPI** 🤙 `CommonQueryParams` 🎓. 👉 ✍ "👐" 👈 🎓 &amp; 👐 🔜 🚶‍♀️ 🔢 `commons` 👆 🔢.
## 🆎 ✍ 🆚 `Depends`
👀 ❔ 👥 ✍ `CommonQueryParams` 🕐 🔛 📟:
```Python
commons: CommonQueryParams = Depends(CommonQueryParams)
```
🏁 `CommonQueryParams`,:
```Python
... = Depends(CommonQueryParams)
```
...⚫️❔ **FastAPI** 🔜 🤙 ⚙️ 💭 ⚫️❔ 🔗.
⚪️➡️ ⚫️ 👈 FastAPI 🔜 ⚗ 📣 🔢 &amp; 👈 ⚫️❔ FastAPI 🔜 🤙 🤙.
---
👉 💼, 🥇 `CommonQueryParams`,:
```Python
commons: CommonQueryParams ...
```
...🚫 ✔️ 🙆 🎁 🔑 **FastAPI**. FastAPI 🏆 🚫 ⚙️ ⚫️ 💽 🛠️, 🔬, ♒️. (⚫️ ⚙️ `= Depends(CommonQueryParams)` 👈).
👆 💪 🤙 ✍:
```Python
commons = Depends(CommonQueryParams)
```
...:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial003.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial003_py310.py!}
```
✋️ 📣 🆎 💡 👈 🌌 👆 👨‍🎨 🔜 💭 ⚫️❔ 🔜 🚶‍♀️ 🔢 `commons`, &amp; ⤴️ ⚫️ 💪 ℹ 👆 ⏮️ 📟 🛠️, 🆎 ✅, ♒️:
<img src="/img/tutorial/dependencies/image02.png">
## ⌨
✋️ 👆 👀 👈 👥 ✔️ 📟 🔁 📥, ✍ `CommonQueryParams` 🕐:
```Python
commons: CommonQueryParams = Depends(CommonQueryParams)
```
**FastAPI** 🚚 ⌨ 👫 💼, 🌐❔ 🔗 *🎯* 🎓 👈 **FastAPI** 🔜 "🤙" ✍ 👐 🎓 ⚫️.
📚 🎯 💼, 👆 💪 📄:
↩️ ✍:
```Python
commons: CommonQueryParams = Depends(CommonQueryParams)
```
...👆 ✍:
```Python
commons: CommonQueryParams = Depends()
```
👆 📣 🔗 🆎 🔢, &amp; 👆 ⚙️ `Depends()` 🚮 "🔢" 💲 (👈 ⏮️ `=`) 👈 🔢 🔢, 🍵 🙆 🔢 `Depends()`, ↩️ ✔️ ✍ 🌕 🎓 *🔄* 🔘 `Depends(CommonQueryParams)`.
🎏 🖼 🔜 ⤴️ 👀 💖:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial004.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial004_py310.py!}
```
...&amp; **FastAPI** 🔜 💭 ⚫️❔.
!!! tip
🚥 👈 😑 🌅 😨 🌘 👍, 🤷‍♂ ⚫️, 👆 🚫 *💪* ⚫️.
⚫️ ⌨. ↩️ **FastAPI** 💅 🔃 🤝 👆 📉 📟 🔁.

71
docs/em/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md

@ -0,0 +1,71 @@
# 🔗 ➡ 🛠️ 👨‍🎨
💼 👆 🚫 🤙 💪 📨 💲 🔗 🔘 👆 *➡ 🛠️ 🔢*.
⚖️ 🔗 🚫 📨 💲.
✋️ 👆 💪 ⚫️ 🛠️/❎.
📚 💼, ↩️ 📣 *➡ 🛠️ 🔢* 🔢 ⏮️ `Depends`, 👆 💪 🚮 `list` `dependencies` *➡ 🛠️ 👨‍🎨*.
## 🚮 `dependencies` *➡ 🛠️ 👨‍🎨*
*➡ 🛠️ 👨‍🎨* 📨 📦 ❌ `dependencies`.
⚫️ 🔜 `list` `Depends()`:
```Python hl_lines="17"
{!../../../docs_src/dependencies/tutorial006.py!}
```
👉 🔗 🔜 🛠️/❎ 🎏 🌌 😐 🔗. ✋️ 👫 💲 (🚥 👫 📨 🙆) 🏆 🚫 🚶‍♀️ 👆 *➡ 🛠️ 🔢*.
!!! tip
👨‍🎨 ✅ ♻ 🔢 🔢, &amp; 🎦 👫 ❌.
⚙️ 👉 `dependencies` *➡ 🛠️ 👨‍🎨* 👆 💪 ⚒ 💭 👫 🛠️ ⏪ ❎ 👨‍🎨/🏭 ❌.
⚫️ 💪 ℹ ❎ 😨 🆕 👩‍💻 👈 👀 ♻ 🔢 👆 📟 &amp; 💪 💭 ⚫️ 🙃.
!!! info
👉 🖼 👥 ⚙️ 💭 🛃 🎚 `X-Key` &amp; `X-Token`.
✋️ 🎰 💼, 🕐❔ 🛠️ 💂‍♂, 👆 🔜 🤚 🌖 💰 ⚪️➡️ ⚙️ 🛠️ [💂‍♂ 🚙 (⏭ 📃)](../security/index.md){.internal-link target=_blank}.
## 🔗 ❌ &amp; 📨 💲
👆 💪 ⚙️ 🎏 🔗 *🔢* 👆 ⚙️ 🛎.
### 🔗 📄
👫 💪 📣 📨 📄 (💖 🎚) ⚖️ 🎏 🎧-🔗:
```Python hl_lines="6 11"
{!../../../docs_src/dependencies/tutorial006.py!}
```
### 🤚 ⚠
👫 🔗 💪 `raise` ⚠, 🎏 😐 🔗:
```Python hl_lines="8 13"
{!../../../docs_src/dependencies/tutorial006.py!}
```
### 📨 💲
&amp; 👫 💪 📨 💲 ⚖️ 🚫, 💲 🏆 🚫 ⚙️.
, 👆 💪 🏤-⚙️ 😐 🔗 (👈 📨 💲) 👆 ⏪ ⚙️ 👱 🙆, &amp; ✋️ 💲 🏆 🚫 ⚙️, 🔗 🔜 🛠️:
```Python hl_lines="9 14"
{!../../../docs_src/dependencies/tutorial006.py!}
```
## 🔗 👪 *➡ 🛠️*
⏪, 🕐❔ 👂 🔃 ❔ 📊 🦏 🈸 ([🦏 🈸 - 💗 📁](../../tutorial/bigger-applications.md){.internal-link target=_blank}), 🎲 ⏮️ 💗 📁, 👆 🔜 💡 ❔ 📣 👁 `dependencies` 🔢 👪 *➡ 🛠️*.
## 🌐 🔗
⏭ 👥 🔜 👀 ❔ 🚮 🔗 🎂 `FastAPI` 🈸, 👈 👫 ✔ 🔠 *➡ 🛠️*.

219
docs/em/docs/tutorial/dependencies/dependencies-with-yield.md

@ -0,0 +1,219 @@
# 🔗 ⏮️ 🌾
FastAPI 🐕‍🦺 🔗 👈 <abbr title='sometimes also called "exit", "cleanup", "teardown", "close", "context managers", ...'>➕ 🔁 ⏮️ 🏁</abbr>.
👉, ⚙️ `yield` ↩️ `return`, &amp; ✍ ➕ 🔁 ⏮️.
!!! tip
⚒ 💭 ⚙️ `yield` 1️⃣ 👁 🕰.
!!! note "📡 ℹ"
🙆 🔢 👈 ☑ ⚙️ ⏮️:
* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager" class="external-link" target="_blank">`@contextlib.contextmanager`</a> ⚖️
* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager" class="external-link" target="_blank">`@contextlib.asynccontextmanager`</a>
🔜 ☑ ⚙️ **FastAPI** 🔗.
👐, FastAPI ⚙️ 📚 2️⃣ 👨‍🎨 🔘.
## 💽 🔗 ⏮️ `yield`
🖼, 👆 💪 ⚙️ 👉 ✍ 💽 🎉 &amp; 🔐 ⚫️ ⏮️ 🏁.
🕴 📟 ⏭ &amp; 🔌 `yield` 📄 🛠️ ⏭ 📨 📨:
```Python hl_lines="2-4"
{!../../../docs_src/dependencies/tutorial007.py!}
```
🌾 💲 ⚫️❔ 💉 🔘 *➡ 🛠️* &amp; 🎏 🔗:
```Python hl_lines="4"
{!../../../docs_src/dependencies/tutorial007.py!}
```
📟 📄 `yield` 📄 🛠️ ⏮️ 📨 ✔️ 🚚:
```Python hl_lines="5-6"
{!../../../docs_src/dependencies/tutorial007.py!}
```
!!! tip
👆 💪 ⚙️ `async` ⚖️ 😐 🔢.
**FastAPI** 🔜 ▶️️ 👜 ⏮️ 🔠, 🎏 ⏮️ 😐 🔗.
## 🔗 ⏮️ `yield` &amp; `try`
🚥 👆 ⚙️ `try` 🍫 🔗 ⏮️ `yield`, 👆 🔜 📨 🙆 ⚠ 👈 🚮 🕐❔ ⚙️ 🔗.
🖼, 🚥 📟 ☝ 🖕, ➕1️⃣ 🔗 ⚖️ *➡ 🛠️*, ⚒ 💽 💵 "💾" ⚖️ ✍ 🙆 🎏 ❌, 👆 🔜 📨 ⚠ 👆 🔗.
, 👆 💪 👀 👈 🎯 ⚠ 🔘 🔗 ⏮️ `except SomeException`.
🎏 🌌, 👆 💪 ⚙️ `finally` ⚒ 💭 🚪 📶 🛠️, 🙅‍♂ 🤔 🚥 📤 ⚠ ⚖️ 🚫.
```Python hl_lines="3 5"
{!../../../docs_src/dependencies/tutorial007.py!}
```
## 🎧-🔗 ⏮️ `yield`
👆 💪 ✔️ 🎧-🔗 &amp; "🌲" 🎧-🔗 🙆 📐 &amp; 💠, &amp; 🙆 ⚖️ 🌐 👫 💪 ⚙️ `yield`.
**FastAPI** 🔜 ⚒ 💭 👈 "🚪 📟" 🔠 🔗 ⏮️ `yield` 🏃 ☑ ✔.
🖼, `dependency_c` 💪 ✔️ 🔗 🔛 `dependency_b`, &amp; `dependency_b` 🔛 `dependency_a`:
```Python hl_lines="4 12 20"
{!../../../docs_src/dependencies/tutorial008.py!}
```
&amp; 🌐 👫 💪 ⚙️ `yield`.
👉 💼 `dependency_c`, 🛠️ 🚮 🚪 📟, 💪 💲 ⚪️➡️ `dependency_b` (📥 📛 `dep_b`) 💪.
&amp; , 🔄, `dependency_b` 💪 💲 ⚪️➡️ `dependency_a` (📥 📛 `dep_a`) 💪 🚮 🚪 📟.
```Python hl_lines="16-17 24-25"
{!../../../docs_src/dependencies/tutorial008.py!}
```
🎏 🌌, 👆 💪 ✔️ 🔗 ⏮️ `yield` &amp; `return` 🌀.
&amp; 👆 💪 ✔️ 👁 🔗 👈 🚚 📚 🎏 🔗 ⏮️ `yield`, ♒️.
👆 💪 ✔️ 🙆 🌀 🔗 👈 👆 💚.
**FastAPI** 🔜 ⚒ 💭 🌐 🏃 ☑ ✔.
!!! note "📡 ℹ"
👉 👷 👏 🐍 <a href="https://docs.python.org/3/library/contextlib.html" class="external-link" target="_blank">🔑 👨‍💼</a>.
**FastAPI** ⚙️ 👫 🔘 🏆 👉.
## 🔗 ⏮️ `yield` &amp; `HTTPException`
👆 👀 👈 👆 💪 ⚙️ 🔗 ⏮️ `yield` &amp; ✔️ `try` 🍫 👈 ✊ ⚠.
⚫️ 5️⃣📆 😋 🤚 `HTTPException` ⚖️ 🎏 🚪 📟, ⏮️ `yield`. ✋️ **⚫️ 🏆 🚫 👷**.
🚪 📟 🔗 ⏮️ `yield` 🛠️ *⏮️* 📨 📨, [⚠ 🐕‍🦺](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank} 🔜 ✔️ ⏪ 🏃. 📤 🕳 😽 ⚠ 🚮 👆 🔗 🚪 📟 (⏮️ `yield`).
, 🚥 👆 🤚 `HTTPException` ⏮️ `yield`, 🔢 (⚖️ 🙆 🛃) ⚠ 🐕‍🦺 👈 ✊ `HTTPException`&amp; 📨 🇺🇸🔍 4️⃣0️⃣0️⃣ 📨 🏆 🚫 📤 ✊ 👈 ⚠ 🚫🔜.
👉 ⚫️❔ ✔ 🕳 ⚒ 🔗 (✅ 💽 🎉), 🖼, ⚙️ 🖥 📋.
🖥 📋 🏃 *⏮️* 📨 ✔️ 📨. 📤 🙅‍♂ 🌌 🤚 `HTTPException` ↩️ 📤 🚫 🌌 🔀 📨 👈 *⏪ 📨*.
✋️ 🚥 🖥 📋 ✍ 💽 ❌, 🌘 👆 💪 💾 ⚖️ 😬 🔐 🎉 🔗 ⏮️ `yield`, &amp; 🎲 🕹 ❌ ⚖️ 📄 ⚫️ 🛰 🕵 ⚙️.
🚥 👆 ✔️ 📟 👈 👆 💭 💪 🤚 ⚠, 🏆 😐/"🙃" 👜 &amp; 🚮 `try` 🍫 👈 📄 📟.
🚥 👆 ✔️ 🛃 ⚠ 👈 👆 🔜 💖 🍵 *⏭* 🛬 📨 &amp; 🎲 ❎ 📨, 🎲 🙋‍♀ `HTTPException`, ✍ [🛃 ⚠ 🐕‍🦺](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}.
!!! tip
👆 💪 🤚 ⚠ 🔌 `HTTPException` *⏭* `yield`. ✋️ 🚫 ⏮️.
🔁 🛠️ 🌅 ⚖️ 🌘 💖 👉 📊. 🕰 💧 ⚪️➡️ 🔝 🔝. &amp; 🔠 🏓 1️⃣ 🍕 🔗 ⚖️ 🛠️ 📟.
```mermaid
sequenceDiagram
participant client as Client
participant handler as Exception handler
participant dep as Dep with yield
participant operation as Path Operation
participant tasks as Background tasks
Note over client,tasks: Can raise exception for dependency, handled after response is sent
Note over client,operation: Can raise HTTPException and can change the response
client ->> dep: Start request
Note over dep: Run code up to yield
opt raise
dep -->> handler: Raise HTTPException
handler -->> client: HTTP error response
dep -->> dep: Raise other exception
end
dep ->> operation: Run dependency, e.g. DB session
opt raise
operation -->> dep: Raise HTTPException
dep -->> handler: Auto forward exception
handler -->> client: HTTP error response
operation -->> dep: Raise other exception
dep -->> handler: Auto forward exception
end
operation ->> client: Return response to client
Note over client,operation: Response is already sent, can't change it anymore
opt Tasks
operation -->> tasks: Send background tasks
end
opt Raise other exception
tasks -->> dep: Raise other exception
end
Note over dep: After yield
opt Handle other exception
dep -->> dep: Handle exception, can't change response. E.g. close DB session.
end
```
!!! info
🕴 **1️⃣ 📨** 🔜 📨 👩‍💻. ⚫️ 💪 1️⃣ ❌ 📨 ⚖️ ⚫️ 🔜 📨 ⚪️➡️ *➡ 🛠️*.
⏮️ 1️⃣ 📚 📨 📨, 🙅‍♂ 🎏 📨 💪 📨.
!!! tip
👉 📊 🎦 `HTTPException`, ✋️ 👆 💪 🤚 🙆 🎏 ⚠ ❔ 👆 ✍ [🛃 ⚠ 🐕‍🦺](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}.
🚥 👆 🤚 🙆 ⚠, ⚫️ 🔜 🚶‍♀️ 🔗 ⏮️ 🌾, 🔌 `HTTPException`, &amp; ⤴️ **🔄** ⚠ 🐕‍🦺. 🚥 📤 🙅‍♂ ⚠ 🐕‍🦺 👈 ⚠, ⚫️ 🔜 ⤴️ 🍵 🔢 🔗 `ServerErrorMiddleware`, 🛬 5️⃣0️⃣0️⃣ 🇺🇸🔍 👔 📟, ➡️ 👩‍💻 💭 👈 📤 ❌ 💽.
## 🔑 👨‍💼
### ⚫️❔ "🔑 👨‍💼"
"🔑 👨‍💼" 🙆 👈 🐍 🎚 👈 👆 💪 ⚙️ `with` 📄.
🖼, <a href="https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files" class="external-link" target="_blank">👆 💪 ⚙️ `with` ✍ 📁</a>:
```Python
with open("./somefile.txt") as f:
contents = f.read()
print(contents)
```
🔘, `open("./somefile.txt")` ✍ 🎚 👈 🤙 "🔑 👨‍💼".
🕐❔ `with` 🍫 🏁, ⚫️ ⚒ 💭 🔐 📁, 🚥 📤 ⚠.
🕐❔ 👆 ✍ 🔗 ⏮️ `yield`, **FastAPI** 🔜 🔘 🗜 ⚫️ 🔑 👨‍💼, &amp; 🌀 ⚫️ ⏮️ 🎏 🔗 🧰.
### ⚙️ 🔑 👨‍💼 🔗 ⏮️ `yield`
!!! warning
👉, 🌅 ⚖️ 🌘, "🏧" 💭.
🚥 👆 ▶️ ⏮️ **FastAPI** 👆 💪 💚 🚶 ⚫️ 🔜.
🐍, 👆 💪 ✍ 🔑 👨‍💼 <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">🏗 🎓 ⏮️ 2️⃣ 👩‍🔬: `__enter__()` &amp; `__exit__()`</a>.
👆 💪 ⚙️ 👫 🔘 **FastAPI** 🔗 ⏮️ `yield` ⚙️
`with` ⚖️ `async with` 📄 🔘 🔗 🔢:
```Python hl_lines="1-9 13"
{!../../../docs_src/dependencies/tutorial010.py!}
```
!!! tip
➕1️⃣ 🌌 ✍ 🔑 👨‍💼 ⏮️:
* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager" class="external-link" target="_blank">`@contextlib.contextmanager`</a> ⚖️
* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager" class="external-link" target="_blank">`@contextlib.asynccontextmanager`</a>
⚙️ 👫 🎀 🔢 ⏮️ 👁 `yield`.
👈 ⚫️❔ **FastAPI** ⚙️ 🔘 🔗 ⏮️ `yield`.
✋️ 👆 🚫 ✔️ ⚙️ 👨‍🎨 FastAPI 🔗 (&amp; 👆 🚫🔜 🚫).
FastAPI 🔜 ⚫️ 👆 🔘.

17
docs/em/docs/tutorial/dependencies/global-dependencies.md

@ -0,0 +1,17 @@
# 🌐 🔗
🆎 🈸 👆 💪 💚 🚮 🔗 🎂 🈸.
🎏 🌌 👆 💪 [🚮 `dependencies` *➡ 🛠️ 👨‍🎨*](dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, 👆 💪 🚮 👫 `FastAPI` 🈸.
👈 💼, 👫 🔜 ✔ 🌐 *➡ 🛠️* 🈸:
```Python hl_lines="15"
{!../../../docs_src/dependencies/tutorial012.py!}
```
&amp; 🌐 💭 📄 🔃 [❎ `dependencies` *➡ 🛠️ 👨‍🎨*](dependencies-in-path-operation-decorators.md){.internal-link target=_blank} ✔, ✋️ 👉 💼, 🌐 *➡ 🛠️* 📱.
## 🔗 👪 *➡ 🛠️*
⏪, 🕐❔ 👂 🔃 ❔ 📊 🦏 🈸 ([🦏 🈸 - 💗 📁](../../tutorial/bigger-applications.md){.internal-link target=_blank}), 🎲 ⏮️ 💗 📁, 👆 🔜 💡 ❔ 📣 👁 `dependencies` 🔢 👪 *➡ 🛠️*.

233
docs/em/docs/tutorial/dependencies/index.md

@ -0,0 +1,233 @@
# 🔗
**FastAPI** ✔️ 📶 🏋️ ✋️ 🏋️ **<abbr title="also known as components, resources, providers, services, injectables">🔗 💉</abbr>** ⚙️.
⚫️ 🏗 📶 🙅 ⚙️, &amp; ⚒ ⚫️ 📶 ⏩ 🙆 👩‍💻 🛠️ 🎏 🦲 ⏮️ **FastAPI**.
## ⚫️❔ "🔗 💉"
**"🔗 💉"** ⛓, 📋, 👈 📤 🌌 👆 📟 (👉 💼, 👆 *➡ 🛠️ 🔢*) 📣 👜 👈 ⚫️ 🚚 👷 &amp; ⚙️: "🔗".
&amp; ⤴️, 👈 ⚙️ (👉 💼 **FastAPI**) 🔜 ✊ 💅 🔨 ⚫️❔ 💪 🚚 👆 📟 ⏮️ 📚 💪 🔗 ("💉" 🔗).
👉 📶 ⚠ 🕐❔ 👆 💪:
* ✔️ 💰 ⚛ (🎏 📟 ⚛ 🔄 &amp; 🔄).
* 💰 💽 🔗.
* 🛠️ 💂‍♂, 🤝, 🔑 📄, ♒️.
* &amp; 📚 🎏 👜...
🌐 👫, ⏪ 📉 📟 🔁.
## 🥇 🔁
➡️ 👀 📶 🙅 🖼. ⚫️ 🔜 🙅 👈 ⚫️ 🚫 📶 ⚠, 🔜.
✋️ 👉 🌌 👥 💪 🎯 🔛 ❔ **🔗 💉** ⚙️ 👷.
### ✍ 🔗, ⚖️ "☑"
➡️ 🥇 🎯 🔛 🔗.
⚫️ 🔢 👈 💪 ✊ 🌐 🎏 🔢 👈 *➡ 🛠️ 🔢* 💪 ✊:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="8-11"
{!> ../../../docs_src/dependencies/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="6-7"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
👈 ⚫️.
**2️⃣ ⏸**.
&amp; ⚫️ ✔️ 🎏 💠 &amp; 📊 👈 🌐 👆 *➡ 🛠️ 🔢* ✔️.
👆 💪 💭 ⚫️ *➡ 🛠️ 🔢* 🍵 "👨‍🎨" (🍵 `@app.get("/some-path")`).
&amp; ⚫️ 💪 📨 🕳 👆 💚.
👉 💼, 👉 🔗 ⌛:
* 📦 🔢 🔢 `q` 👈 `str`.
* 📦 🔢 🔢 `skip` 👈 `int`, &amp; 🔢 `0`.
* 📦 🔢 🔢 `limit` 👈 `int`, &amp; 🔢 `100`.
&amp; ⤴️ ⚫️ 📨 `dict` ⚗ 📚 💲.
### 🗄 `Depends`
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="1"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
### 📣 🔗, "⚓️"
🎏 🌌 👆 ⚙️ `Body`, `Query`, ♒️. ⏮️ 👆 *➡ 🛠️ 🔢* 🔢, ⚙️ `Depends` ⏮️ 🆕 🔢:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="15 20"
{!> ../../../docs_src/dependencies/tutorial001.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="11 16"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
👐 👆 ⚙️ `Depends` 🔢 👆 🔢 🎏 🌌 👆 ⚙️ `Body`, `Query`, ♒️, `Depends` 👷 👄 🎏.
👆 🕴 🤝 `Depends` 👁 🔢.
👉 🔢 🔜 🕳 💖 🔢.
&amp; 👈 🔢 ✊ 🔢 🎏 🌌 👈 *➡ 🛠️ 🔢* .
!!! tip
👆 🔜 👀 ⚫️❔ 🎏 "👜", ↖️ ⚪️➡️ 🔢, 💪 ⚙️ 🔗 ⏭ 📃.
🕐❔ 🆕 📨 🛬, **FastAPI** 🔜 ✊ 💅:
* 🤙 👆 🔗 ("☑") 🔢 ⏮️ ☑ 🔢.
* 🤚 🏁 ⚪️➡️ 👆 🔢.
* 🛠️ 👈 🏁 🔢 👆 *➡ 🛠️ 🔢*.
```mermaid
graph TB
common_parameters(["common_parameters"])
read_items["/items/"]
read_users["/users/"]
common_parameters --> read_items
common_parameters --> read_users
```
👉 🌌 👆 ✍ 🔗 📟 🕐 &amp; **FastAPI** ✊ 💅 🤙 ⚫️ 👆 *➡ 🛠️*.
!!! check
👀 👈 👆 🚫 ✔️ ✍ 🎁 🎓 &amp; 🚶‍♀️ ⚫️ 👱 **FastAPI** "®" ⚫️ ⚖️ 🕳 🎏.
👆 🚶‍♀️ ⚫️ `Depends` &amp; **FastAPI** 💭 ❔ 🎂.
## `async` ⚖️ 🚫 `async`
🔗 🔜 🤙 **FastAPI** (🎏 👆 *➡ 🛠️ 🔢*), 🎏 🚫 ✔ ⏪ 🔬 👆 🔢.
👆 💪 ⚙️ `async def` ⚖️ 😐 `def`.
&amp; 👆 💪 📣 🔗 ⏮️ `async def` 🔘 😐 `def` *➡ 🛠️ 🔢*, ⚖️ `def` 🔗 🔘 `async def` *➡ 🛠️ 🔢*, ♒️.
⚫️ 🚫 🤔. **FastAPI** 🔜 💭 ⚫️❔.
!!! note
🚥 👆 🚫 💭, ✅ [🔁: *"🏃 ❓" *](../../async.md){.internal-link target=_blank} 📄 🔃 `async` &amp; `await` 🩺.
## 🛠️ ⏮️ 🗄
🌐 📨 📄, 🔬 &amp; 📄 👆 🔗 (&amp; 🎧-🔗) 🔜 🛠️ 🎏 🗄 🔗.
, 🎓 🩺 🔜 ✔️ 🌐 ℹ ⚪️➡️ 👫 🔗 💁‍♂️:
<img src="/img/tutorial/dependencies/image01.png">
## 🙅 ⚙️
🚥 👆 👀 ⚫️, *➡ 🛠️ 🔢* 📣 ⚙️ 🕐❔ *➡* &amp; *🛠️* 🏏, &amp; ⤴️ **FastAPI** ✊ 💅 🤙 🔢 ⏮️ ☑ 🔢, ❎ 📊 ⚪️➡️ 📨.
🤙, 🌐 (⚖️ 🏆) 🕸 🛠️ 👷 👉 🎏 🌌.
👆 🙅 🤙 👈 🔢 🔗. 👫 🤙 👆 🛠️ (👉 💼, **FastAPI**).
⏮️ 🔗 💉 ⚙️, 👆 💪 💬 **FastAPI** 👈 👆 *➡ 🛠️ 🔢* "🪀" 🔛 🕳 🙆 👈 🔜 🛠️ ⏭ 👆 *➡ 🛠️ 🔢*, &amp; **FastAPI** 🔜 ✊ 💅 🛠️ ⚫️ &amp; "💉" 🏁.
🎏 ⚠ ⚖ 👉 🎏 💭 "🔗 💉":
* ℹ
* 🐕‍🦺
* 🐕‍🦺
* 💉
* 🦲
## **FastAPI** 🔌-🔌
🛠️ &amp; "🔌-"Ⓜ 💪 🏗 ⚙️ **🔗 💉** ⚙️. ✋️ 👐, 📤 🤙 **🙅‍♂ 💪 ✍ "🔌-🔌"**, ⚙️ 🔗 ⚫️ 💪 📣 ♾ 🔢 🛠️ &amp; 🔗 👈 ▶️️ 💪 👆 *➡ 🛠️ 🔢*.
&amp; 🔗 💪 ✍ 📶 🙅 &amp; 🏋️ 🌌 👈 ✔ 👆 🗄 🐍 📦 👆 💪, &amp; 🛠️ 👫 ⏮️ 👆 🛠️ 🔢 👩‍❤‍👨 ⏸ 📟, *🌖*.
👆 🔜 👀 🖼 👉 ⏭ 📃, 🔃 🔗 &amp; ☁ 💽, 💂‍♂, ♒️.
## **FastAPI** 🔗
🦁 🔗 💉 ⚙️ ⚒ **FastAPI** 🔗 ⏮️:
* 🌐 🔗 💽
* ☁ 💽
* 🔢 📦
* 🔢 🔗
* 🤝 &amp; ✔ ⚙️
* 🛠️ ⚙️ ⚖ ⚙️
* 📨 💽 💉 ⚙️
* ♒️.
## 🙅 &amp; 🏋️
👐 🔗 🔗 💉 ⚙️ 📶 🙅 🔬 &amp; ⚙️, ⚫️ 📶 🏋️.
👆 💪 🔬 🔗 👈 🔄 💪 🔬 🔗 👫.
🔚, 🔗 🌲 🔗 🏗, &amp; **🔗 💉** ⚙️ ✊ 💅 🔬 🌐 👉 🔗 👆 (&amp; 👫 🎧-🔗) &amp; 🚚 (💉) 🏁 🔠 🔁.
🖼, ➡️ 💬 👆 ✔️ 4️⃣ 🛠️ 🔗 (*➡ 🛠️*):
* `/items/public/`
* `/items/private/`
* `/users/{user_id}/activate`
* `/items/pro/`
⤴️ 👆 💪 🚮 🎏 ✔ 📄 🔠 👫 ⏮️ 🔗 &amp; 🎧-🔗:
```mermaid
graph TB
current_user(["current_user"])
active_user(["active_user"])
admin_user(["admin_user"])
paying_user(["paying_user"])
public["/items/public/"]
private["/items/private/"]
activate_user["/users/{user_id}/activate"]
pro_items["/items/pro/"]
current_user --> active_user
active_user --> admin_user
active_user --> paying_user
current_user --> public
active_user --> private
admin_user --> activate_user
paying_user --> pro_items
```
## 🛠️ ⏮️ **🗄**
🌐 👫 🔗, ⏪ 📣 👫 📄, 🚮 🔢, 🔬, ♒️. 👆 *➡ 🛠️*.
**FastAPI** 🔜 ✊ 💅 🚮 ⚫️ 🌐 🗄 🔗, 👈 ⚫️ 🎦 🎓 🧾 ⚙️.

110
docs/em/docs/tutorial/dependencies/sub-dependencies.md

@ -0,0 +1,110 @@
# 🎧-🔗
👆 💪 ✍ 🔗 👈 ✔️ **🎧-🔗**.
👫 💪 **⏬** 👆 💪 👫.
**FastAPI** 🔜 ✊ 💅 🔬 👫.
## 🥇 🔗 "☑"
👆 💪 ✍ 🥇 🔗 ("☑") 💖:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="8-9"
{!> ../../../docs_src/dependencies/tutorial005.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="6-7"
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
⚫️ 📣 📦 🔢 🔢 `q` `str`, &amp; ⤴️ ⚫️ 📨 ⚫️.
👉 🙅 (🚫 📶 ⚠), ✋️ 🔜 ℹ 👥 🎯 🔛 ❔ 🎧-🔗 👷.
## 🥈 🔗, "☑" &amp; "⚓️"
⤴️ 👆 💪 ✍ ➕1️⃣ 🔗 🔢 ("☑") 👈 🎏 🕰 📣 🔗 🚮 👍 (⚫️ "⚓️" 💁‍♂️):
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial005.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
➡️ 🎯 🔛 🔢 📣:
* ✋️ 👉 🔢 🔗 ("☑") ⚫️, ⚫️ 📣 ➕1️⃣ 🔗 (⚫️ "🪀" 🔛 🕳 🙆).
* ⚫️ 🪀 🔛 `query_extractor`, &amp; 🛠️ 💲 📨 ⚫️ 🔢 `q`.
* ⚫️ 📣 📦 `last_query` 🍪, `str`.
* 🚥 👩‍💻 🚫 🚚 🙆 🔢 `q`, 👥 ⚙️ 🏁 🔢 ⚙️, ❔ 👥 🖊 🍪 ⏭.
## ⚙️ 🔗
⤴️ 👥 💪 ⚙️ 🔗 ⏮️:
=== "🐍 3️⃣.6️⃣ &amp; 🔛"
```Python hl_lines="22"
{!> ../../../docs_src/dependencies/tutorial005.py!}
```
=== "🐍 3️⃣.1️⃣0️⃣ &amp; 🔛"
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
!!! info
👀 👈 👥 🕴 📣 1️⃣ 🔗 *➡ 🛠️ 🔢*, `query_or_cookie_extractor`.
✋️ **FastAPI** 🔜 💭 👈 ⚫️ ✔️ ❎ `query_extractor` 🥇, 🚶‍♀️ 🏁 👈 `query_or_cookie_extractor` ⏪ 🤙 ⚫️.
```mermaid
graph TB
query_extractor(["query_extractor"])
query_or_cookie_extractor(["query_or_cookie_extractor"])
read_query["/items/"]
query_extractor --> query_or_cookie_extractor --> read_query
```
## ⚙️ 🎏 🔗 💗 🕰
🚥 1️⃣ 👆 🔗 📣 💗 🕰 🎏 *➡ 🛠️*, 🖼, 💗 🔗 ✔️ ⚠ 🎧-🔗, **FastAPI** 🔜 💭 🤙 👈 🎧-🔗 🕴 🕐 📍 📨.
&amp; ⚫️ 🔜 🖊 📨 💲 <abbr title="A utility/system to store computed/generated values, to re-use them instead of computing them again.">"💾"</abbr> &amp; 🚶‍♀️ ⚫️ 🌐 "⚓️" 👈 💪 ⚫️ 👈 🎯 📨, ↩️ 🤙 🔗 💗 🕰 🎏 📨.
🏧 😐 🌐❔ 👆 💭 👆 💪 🔗 🤙 🔠 🔁 (🎲 💗 🕰) 🎏 📨 ↩️ ⚙️ "💾" 💲, 👆 💪 ⚒ 🔢 `use_cache=False` 🕐❔ ⚙️ `Depends`:
```Python hl_lines="1"
async def needy_dependency(fresh_value: str = Depends(get_value, use_cache=False)):
return {"fresh_value": fresh_value}
```
## 🌃
↖️ ⚪️➡️ 🌐 🎀 🔤 ⚙️ 📥, **🔗 💉** ⚙️ 🙅.
🔢 👈 👀 🎏 *➡ 🛠️ 🔢*.
✋️, ⚫️ 📶 🏋️, &amp; ✔ 👆 📣 🎲 🙇 🐦 🔗 "📊" (🌲).
!!! tip
🌐 👉 💪 🚫 😑 ⚠ ⏮️ 👫 🙅 🖼.
✋️ 👆 🔜 👀 ❔ ⚠ ⚫️ 📃 🔃 **💂‍♂**.
&amp; 👆 🔜 👀 💸 📟 ⚫️ 🔜 🖊 👆.

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save