Compare commits

...

288 Commits

Author SHA1 Message Date
Sebastián Ramírez
07684aea79 🔖 Release version 0.115.2 2024-10-12 12:00:47 +02:00
github-actions
63c428fbf9 📝 Update release notes 2024-10-12 09:59:23 +00:00
Sebastián Ramírez
b77f2351d1 ⬆️ Upgrade Starlette to >=0.37.2,<0.41.0 (#12431) 2024-10-12 11:59:01 +02:00
Sebastián Ramírez
113da5b0a7 🔖 Release version 0.115.1 2024-10-12 11:51:09 +02:00
github-actions
f0be768646 📝 Update release notes 2024-10-12 09:45:17 +00:00
Felix Fanghaenel
e049fc4ea1 🐛 Fix openapi generation with responses kwarg (#10895)
Co-authored-by: flxdot <felix.fanghaenel@nitrex.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: Sławek Ehlert <slawomir.ehlert@gmail.com>
2024-10-12 11:44:57 +02:00
github-actions
b29cf1621a 📝 Update release notes 2024-10-12 09:36:55 +00:00
José Pacheco
8ae4603d68 🐛 Remove Required shadowing from fastapi using Pydantic v2 (#12197)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2024-10-12 11:36:32 +02:00
github-actions
529155e72e 📝 Update release notes 2024-10-09 20:12:15 +00:00
pre-commit-ci[bot]
104dc0b8d8 ⬆ [pre-commit.ci] pre-commit autoupdate (#12396)
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.6.8 → v0.6.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.8...v0.6.9)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-09 22:11:46 +02:00
github-actions
dbb4a91e12 📝 Update release notes 2024-10-09 19:45:08 +00:00
Sebastián Ramírez
7daaac2bc3 Add new tutorial for SQL databases with SQLModel (#12285) 2024-10-09 21:44:42 +02:00
github-actions
13a18f80b3 📝 Update release notes 2024-10-08 11:01:43 +00:00
Sebastián Ramírez
c6dfdb8523 🔨 Add script to generate variants of files (#12405) 2024-10-08 11:01:17 +00:00
github-actions
a94d61b2c0 📝 Update release notes 2024-10-08 10:55:50 +00:00
Sebastián Ramírez
40490abaa3 ♻️ Update type annotations for improved python-multipart (#12407) 2024-10-08 12:55:26 +02:00
github-actions
fcb15b4db1 📝 Update release notes 2024-10-08 08:38:00 +00:00
Sebastián Ramírez
018e303fd9 🔧 Add speakeasy-api to sponsors_badge.yml (#12404) 2024-10-08 08:37:32 +00:00
github-actions
6345147c24 📝 Update release notes 2024-10-07 20:25:03 +00:00
Sebastián Ramírez
95f167f048 Add docs dependency: markdown-include-variants (#12399) 2024-10-07 20:24:40 +00:00
github-actions
ecc4133907 📝 Update release notes 2024-10-07 20:18:29 +00:00
Sebastián Ramírez
797cad7162 📝 Fix extra mdx-base-path paths (#12397) 2024-10-07 20:18:07 +00:00
github-actions
e45b5d3589 📝 Update release notes 2024-10-07 20:11:42 +00:00
Sebastián Ramírez
b45192c68a 👷 Tweak labeler to not override custom labels (#12398) 2024-10-07 20:11:20 +00:00
github-actions
31aec0967a 📝 Update release notes 2024-10-07 11:32:19 +00:00
Balthazar Rouberol
e9c6408af7 📝 Add External Link: How to profile a FastAPI asynchronous request (#12389) 2024-10-07 11:31:55 +00:00
github-actions
3f8a527b50 📝 Update release notes 2024-10-07 11:23:42 +00:00
Rafael de Oliveira Marques
e62960e323 🌐 Add Portuguese translation for docs/pt/docs/tutorial/cookie-param-models.md (#12298) 2024-10-07 13:23:18 +02:00
github-actions
b36b7dfed0 📝 Update release notes 2024-10-06 20:37:15 +00:00
Sebastián Ramírez
0f7d67e85c 🔧 Remove base_path for mdx_include Markdown extension in MkDocs (#12391) 2024-10-06 22:36:54 +02:00
github-actions
c67b41546c 📝 Update release notes 2024-10-06 20:14:33 +00:00
Sebastián Ramírez
1705a8c37f 👷 Update deploy-docs-notify URL (#12392) 2024-10-06 20:14:05 +00:00
github-actions
ad8b3ba3ec 📝 Update release notes 2024-10-05 12:49:28 +00:00
Sebastián Ramírez
9d6ec4aa77 👷 Update Cloudflare GitHub Action (#12387) 2024-10-05 14:49:04 +02:00
github-actions
ea1265b78b 📝 Update release notes 2024-10-04 11:58:03 +00:00
dependabot[bot]
caa298aefe ⬆ Bump pypa/gh-action-pypi-publish from 1.10.1 to 1.10.3 (#12386)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.1 to 1.10.3.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.1...v1.10.3)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-04 13:57:23 +02:00
github-actions
82b95dcef8 📝 Update release notes 2024-10-04 11:56:57 +00:00
dependabot[bot]
757eaacd59 ⬆ Bump mkdocstrings[python] from 0.25.1 to 0.26.1 (#12371)
Bumps [mkdocstrings[python]](https://github.com/mkdocstrings/mkdocstrings) from 0.25.1 to 0.26.1.
- [Release notes](https://github.com/mkdocstrings/mkdocstrings/releases)
- [Changelog](https://github.com/mkdocstrings/mkdocstrings/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mkdocstrings/mkdocstrings/compare/0.25.1...0.26.1)

---
updated-dependencies:
- dependency-name: mkdocstrings[python]
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alejandra <90076947+alejsdev@users.noreply.github.com>
2024-10-04 13:56:35 +02:00
github-actions
deec2e591e 📝 Update release notes 2024-10-04 11:39:01 +00:00
dependabot[bot]
8953d9a323 ⬆ Bump griffe-typingdoc from 0.2.6 to 0.2.7 (#12370)
Bumps [griffe-typingdoc](https://github.com/mkdocstrings/griffe-typingdoc) from 0.2.6 to 0.2.7.
- [Release notes](https://github.com/mkdocstrings/griffe-typingdoc/releases)
- [Changelog](https://github.com/mkdocstrings/griffe-typingdoc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mkdocstrings/griffe-typingdoc/compare/0.2.6...0.2.7)

---
updated-dependencies:
- dependency-name: griffe-typingdoc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-04 13:37:26 +02:00
github-actions
d12db0b26c 📝 Update release notes 2024-10-04 11:36:26 +00:00
Pavlo Pohorieltsev
3f3a3dd664 📝 Update link to Swagger UI configuration docs (#12264) 2024-10-04 13:34:57 +02:00
github-actions
f2fb0251cc 📝 Update release notes 2024-10-04 11:26:21 +00:00
pre-commit-ci[bot]
a096615f79 ⬆ [pre-commit.ci] pre-commit autoupdate (#12331)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.7 → v0.6.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.7...v0.6.8)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-04 13:21:41 +02:00
github-actions
3d24833272 📝 Update release notes 2024-10-04 11:20:57 +00:00
github-actions
c08b80d09f 📝 Update release notes 2024-10-04 11:20:35 +00:00
Kayque Govetri
c93810e097 📝 Adding links for Playwright and Vite in docs/project-generation.md (#12274) 2024-10-04 13:16:34 +02:00
AnandaCampelo
a681aeba6d 🌐 Add Portuguese translation for docs/pt/docs/how-to/graphql.md (#12215) 2024-10-04 13:15:21 +02:00
github-actions
e2217e24b9 📝 Update release notes 2024-10-04 11:14:33 +00:00
Rafael de Oliveira Marques
0e7806e3f9 🌐 Add Portuguese translation for docs/pt/docs/advanced/security/oauth2-scopes.md (#12263) 2024-10-04 13:11:41 +02:00
github-actions
5820d4261e 📝 Update release notes 2024-10-04 11:10:09 +00:00
github-actions
304f514ed9 📝 Update release notes 2024-10-04 11:08:00 +00:00
marcelomarkus
17e234452a 🌐 Add Portuguese translation for docs/pt/docs/deployment/concepts.md (#12219) 2024-10-04 13:04:50 +02:00
marcelomarkus
fa50b0c73c 🌐 Add Portuguese translation for docs/pt/docs/how-to/conditional-openapi.md (#12221) 2024-10-04 13:03:46 +02:00
github-actions
b1c03ba57e 📝 Update release notes 2024-10-04 11:03:27 +00:00
github-actions
98d190f780 📝 Update release notes 2024-10-04 11:01:25 +00:00
João Pedro Pereira Holanda
69921b463e 🌐 Add Portuguese translation for docs/pt/docs/advanced/response-directly.md (#12266) 2024-10-04 13:00:29 +02:00
github-actions
ed477ee887 📝 Update release notes 2024-10-04 10:58:40 +00:00
Rafael de Oliveira Marques
ca68c99a6e 🌐 Update Portuguese translation for docs/pt/docs/tutorial/cookie-params.md (#12297) 2024-10-04 12:58:03 +02:00
kkotipy
0030f1749e 🌐 Fix Korean translation for docs/ko/docs/tutorial/index.md (#12278) 2024-10-04 10:57:17 +00:00
github-actions
919721ce8d 📝 Update release notes 2024-10-04 10:56:12 +00:00
Anderson Rocha
f0ebae6e9e 🌐 Update Portuguese translation for docs/pt/docs/advanced/security/http-basic-auth.md (#12275) 2024-10-04 12:55:49 +02:00
github-actions
847296e885 📝 Update release notes 2024-09-26 17:17:48 +00:00
Sebastián Ramírez
bb018fc46c 🔧 Update sponsors, remove Fine.dev (#12271) 2024-09-26 17:17:21 +00:00
github-actions
10f3cb5ab1 📝 Update release notes 2024-09-24 10:14:28 +00:00
pre-commit-ci[bot]
d9e989e274 ⬆ [pre-commit.ci] pre-commit autoupdate (#12253)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.5 → v0.6.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.5...v0.6.7)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-09-24 12:14:00 +02:00
github-actions
9606b916ef 📝 Update release notes 2024-09-21 21:38:11 +00:00
marcelomarkus
6a2ad7031c 🌐 Add Portuguese translation for docs/pt/docs/deployment/cloud.md (#12217) 2024-09-21 23:37:48 +02:00
github-actions
f6dfb832c5 📝 Update release notes 2024-09-20 11:34:29 +00:00
Javier Sánchez Castro
2cdf111e61 ✏️ Fix typo in docs/es/docs/python-types.md (#12235) 2024-09-20 11:34:07 +00:00
github-actions
13e20228a9 📝 Update release notes 2024-09-20 11:15:35 +00:00
Max Scheijen
6aefc31600 🌐 Add Dutch translation for docs/nl/docs/environment-variables.md (#12200) 2024-09-20 13:13:32 +02:00
github-actions
2459a009f4 📝 Update release notes 2024-09-20 11:11:21 +00:00
João Gustavo Rogel de Oliveira
b1024e73be 🌐 Add Portuguese translation for docs/pt/docs/deployment/manually.md (#12210) 2024-09-20 13:10:02 +02:00
github-actions
4e3db0b689 📝 Update release notes 2024-09-20 11:03:12 +00:00
marcelomarkus
0b1da2d910 🌐 Add Portuguese translation for docs/pt/docs/deployment/server-workers.md (#12220) 2024-09-20 13:01:03 +02:00
github-actions
cf93157be7 📝 Update release notes 2024-09-20 11:00:31 +00:00
marcelomarkus
97ac2286aa 🌐 Add Portuguese translation for docs/pt/docs/how-to/configure-swagger-ui.md (#12222) 2024-09-20 13:00:08 +02:00
github-actions
7c6f2f8fde 📝 Update release notes 2024-09-19 09:47:54 +00:00
Albert Villanova del Moral
6cc24416e2 ✏️ Fix docstring typos in http security (#12223)
Fix docstring typos in http security
2024-09-19 11:47:28 +02:00
github-actions
4d6cab3ec6 📝 Update release notes 2024-09-18 16:10:21 +00:00
Sofie Van Landeghem
42e0e368bc 📝 Fix small typos in the documentation (#12213) 2024-09-18 18:09:57 +02:00
Sebastián Ramírez
40e33e492d 🔖 Release version 0.115.0 2024-09-17 21:07:35 +02:00
Sebastián Ramírez
b36047b54a 📝 Update release notes 2024-09-17 21:06:26 +02:00
github-actions
7eadeb69bd 📝 Update release notes 2024-09-17 18:54:35 +00:00
Sebastián Ramírez
55035f440b Add support for Pydantic models for parameters using Query, Cookie, Header (#12199) 2024-09-17 20:54:10 +02:00
github-actions
0903da78c9 📝 Update release notes 2024-09-16 22:00:35 +00:00
pre-commit-ci[bot]
4b2b14a8e8 ⬆ [pre-commit.ci] pre-commit autoupdate (#12204)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.4 → v0.6.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.4...v0.6.5)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-09-17 00:00:09 +02:00
github-actions
35df20c79c 📝 Update release notes 2024-09-15 19:04:38 +00:00
Rafael de Oliveira Marques
8eb3c5621f 🌐 Add Portuguese translation for docs/pt/docs/advanced/security/http-basic-auth.md (#12195) 2024-09-15 21:04:17 +02:00
Sebastián Ramírez
2ada1615a3 🔖 Release version 0.114.2 2024-09-13 22:46:33 +02:00
github-actions
3a5fd71f55 📝 Update release notes 2024-09-13 09:51:26 +00:00
Nico Tonnhofer
88d4f2cb18 🐛 Fix form field regression (#12194) 2024-09-13 11:51:00 +02:00
github-actions
0fc6e34135 📝 Update release notes 2024-09-13 09:15:10 +00:00
Sebastián Ramírez
2a4351105e 💡 Add comments with instructions for Playwright screenshot scripts (#12193) 2024-09-13 11:14:46 +02:00
github-actions
ed66d70513 📝 Update release notes 2024-09-12 17:06:34 +00:00
Rafael de Oliveira Marques
e50facaf22 🌐 Add Portuguese translation for docs/pt/docs/tutorial/request-form-models.md (#12175) 2024-09-12 19:03:48 +02:00
github-actions
93e50e373b 📝 Update release notes 2024-09-12 17:03:26 +00:00
Waket Zheng
4a94fe3c82 🌐 Add Chinese translation for docs/zh/docs/project-generation.md (#12170) 2024-09-12 19:01:54 +02:00
github-actions
492943fdb1 📝 Update release notes 2024-09-12 17:01:01 +00:00
Max Scheijen
c8e644d19e 🌐 Add Dutch translation for docs/nl/docs/python-types.md (#12158) 2024-09-12 19:00:36 +02:00
github-actions
ba0bb6212e 📝 Update release notes 2024-09-11 22:50:18 +00:00
Sebastián Ramírez
24b8f2668b Add inline-snapshot for tests (#12189) 2024-09-11 22:49:55 +00:00
Sebastián Ramírez
212fd5e247 🔖 Release version 0.114.1 2024-09-11 09:46:34 +02:00
github-actions
8dc882f751 📝 Update release notes 2024-09-11 07:45:49 +00:00
Sebastián Ramírez
b0eedbb580 ️ Improve performance in request body parsing with a cache for internal model fields (#12184) 2024-09-11 09:45:30 +02:00
github-actions
74451189f6 📝 Update release notes 2024-09-10 10:40:52 +00:00
github-actions
a4c5f7f62f 📝 Update release notes 2024-09-10 10:38:58 +00:00
github-actions
eb45bade63 📝 Update release notes 2024-09-10 10:37:36 +00:00
marcelomarkus
944b6e507e 🌐 Add Portuguese translation for docs/pt/docs/virtual-environments.md (#12163) 2024-09-10 12:37:13 +02:00
marcelomarkus
e69ba26386 🌐 Add Portuguese translation for docs/pt/docs/environment-variables.md (#12162) 2024-09-10 12:36:42 +02:00
marcelomarkus
a4a7925045 🌐 Add Portuguese translation for docs/pt/docs/tutorial/testing.md (#12164) 2024-09-10 12:35:14 +02:00
github-actions
73d4f347df 📝 Update release notes 2024-09-10 10:34:46 +00:00
marcelomarkus
80e2cd1274 🌐 Add Portuguese translation for docs/pt/docs/tutorial/debugging.md (#12165) 2024-09-10 12:34:25 +02:00
github-actions
bc715d55bc 📝 Update release notes 2024-09-10 09:08:09 +00:00
dependabot[bot]
fc601bcb4b ⬆ Bump tiangolo/issue-manager from 0.5.0 to 0.5.1 (#12173)
Bumps [tiangolo/issue-manager](https://github.com/tiangolo/issue-manager) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/tiangolo/issue-manager/releases)
- [Commits](https://github.com/tiangolo/issue-manager/compare/0.5.0...0.5.1)

---
updated-dependencies:
- dependency-name: tiangolo/issue-manager
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-10 11:07:46 +02:00
github-actions
da4670cf77 📝 Update release notes 2024-09-09 18:36:15 +00:00
pre-commit-ci[bot]
a67167dce3 ⬆ [pre-commit.ci] pre-commit autoupdate (#12176)
* ⬆ [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.6.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.3...v0.6.4)

* bump ruff in tests requirements as well

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
2024-09-09 20:35:50 +02:00
github-actions
c49c4e7df8 📝 Update release notes 2024-09-08 20:37:14 +00:00
Guillaume Fassot
270aef71c4 📝 Remove duplicate line in docs for docs/en/docs/environment-variables.md (#12169) 2024-09-08 22:36:53 +02:00
github-actions
3a4431b6fe 📝 Update release notes 2024-09-07 23:36:05 +00:00
BORA
ec2a508292 🌐 Add Korean translation for docs/ko/docs/project-generation.md (#12157) 2024-09-08 01:35:43 +02:00
github-actions
b501fc6daf 📝 Update release notes 2024-09-07 15:24:06 +00:00
Sebastián Ramírez
edb584199f 👷 Update issue-manager.yml (#12159) 2024-09-07 17:21:14 +02:00
github-actions
4b9e5b3a74 📝 Update release notes 2024-09-06 18:06:45 +00:00
Vaibhav
b60d36e753 ✏️ Fix typo in fastapi/params.py (#12143) 2024-09-06 20:06:20 +02:00
Sebastián Ramírez
bde12faea2 🔖 Release version 0.114.0 2024-09-06 19:41:13 +02:00
Sebastián Ramírez
74842f0a60 📝 Update release notes 2024-09-06 19:40:27 +02:00
github-actions
e68d8c60fb 📝 Update release notes 2024-09-06 17:38:50 +00:00
Sebastián Ramírez
4ff22a0c41 📝 Update docs, Form Models section title, to match config name (#12152) 2024-09-06 17:38:23 +00:00
github-actions
a11e392f5f 📝 Update release notes 2024-09-06 17:31:44 +00:00
Sebastián Ramírez
4633b1bca9 Add support for forbidding extra form fields with Pydantic models (#12134)
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2024-09-06 19:31:18 +02:00
github-actions
1b06b53267 📝 Update release notes 2024-09-06 15:58:05 +00:00
Sebastián Ramírez
c411b81c29 Update internal tests for latest Pydantic, including CI tweaks to install the latest Pydantic (#12147) 2024-09-06 15:57:43 +00:00
Sebastián Ramírez
d86f660302 🔖 Release version 0.113.0 2024-09-05 17:25:29 +02:00
github-actions
179f838c36 📝 Update release notes 2024-09-05 15:23:05 +00:00
Sebastián Ramírez
afdda4e50b 🔧 Update sponsors: Coherence link (#12130) 2024-09-05 15:21:35 +00:00
github-actions
e787f854dd 📝 Update release notes 2024-09-05 15:17:13 +00:00
Sebastián Ramírez
7bad7c0975 Add support for Pydantic models in Form parameters (#12129)
Revert "️ Temporarily revert " Add support for Pydantic models in `Form` pa…"

This reverts commit 8e6cf9ee9c.
2024-09-05 17:16:50 +02:00
Sebastián Ramírez
965fc8301e 📝 Update release notes 2024-09-05 17:09:31 +02:00
Sebastián Ramírez
999eeb6c76 🔖 Release version 0.112.4 2024-09-05 17:00:33 +02:00
Sebastián Ramírez
96c7e7e0f3 📝 Update release notes 2024-09-05 17:00:13 +02:00
Sebastián Ramírez
8224addd8f 📝 Update release notes 2024-09-05 16:57:57 +02:00
github-actions
b69e8b24af 📝 Update release notes 2024-09-05 14:56:10 +00:00
Sebastián Ramírez
8e6cf9ee9c ️ Temporarily revert " Add support for Pydantic models in Form parameters" to make a checkpoint release (#12128)
Revert " Add support for Pydantic models in `Form` parameters (#12127)"

This reverts commit 0f3e65b007.
2024-09-05 16:55:44 +02:00
github-actions
ccb19c4c35 📝 Update release notes 2024-09-05 14:41:11 +00:00
Sebastián Ramírez
0f3e65b007 Add support for Pydantic models in Form parameters (#12127) 2024-09-05 16:40:48 +02:00
github-actions
832e634fd4 📝 Update release notes 2024-09-05 11:25:02 +00:00
Sebastián Ramírez
aa21814a89 ♻️ Refactor deciding if embed body fields, do not overwrite fields, compute once per router, refactor internals in preparation for Pydantic models in Form, Query and others (#12117) 2024-09-05 13:24:36 +02:00
Sebastián Ramírez
7213d421f5 🔖 Release version 0.112.3 2024-09-05 11:13:32 +02:00
github-actions
68e5ef6968 📝 Update release notes 2024-09-05 09:07:55 +00:00
pre-commit-ci[bot]
1f64a1bb55 ⬆ [pre-commit.ci] pre-commit autoupdate (#12115)
* ⬆ [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.2 → v0.6.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.2...v0.6.3)

* bump ruff as well

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
2024-09-05 11:07:32 +02:00
github-actions
9b2a9333b3 📝 Update release notes 2024-09-03 16:05:42 +00:00
Shubhendra Kushwaha
f42fd9aac2 📝 Add External Link: Techniques and applications of SQLAlchemy global filters in FastAPI (#12109) 2024-09-03 18:05:19 +02:00
github-actions
cbdc58b1b7 📝 Update release notes 2024-09-03 13:54:00 +00:00
Max Scheijen
3feed9dd8c 🌐 Add Dutch translation for docs/nl/docs/features.md (#12101) 2024-09-03 15:50:38 +02:00
github-actions
560c43269d 📝 Update release notes 2024-09-03 13:49:34 +00:00
dependabot[bot]
7eae925443 ⬆ Bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1 (#12120)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.0...v1.10.1)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-03 15:47:08 +02:00
github-actions
7d69943a22 📝 Update release notes 2024-09-03 13:45:21 +00:00
github-actions
56cfecc1bf 📝 Update release notes 2024-09-03 13:44:55 +00:00
Rafael de Oliveira Marques
e26229ed98 🌐 Add Portuguese translation for docs/pt/docs/advanced/testing-events.md (#12108) 2024-09-03 15:44:35 +02:00
Rafael de Oliveira Marques
c1c57336b0 🌐 Add Portuguese translation for docs/pt/docs/advanced/security/index.md (#12114) 2024-09-03 15:43:56 +02:00
github-actions
7537bac43f 📝 Update release notes 2024-09-03 13:15:41 +00:00
dependabot[bot]
6b3d1c6d4e ⬆ Bump pillow from 10.3.0 to 10.4.0 (#12105)
Bumps [pillow](https://github.com/python-pillow/Pillow) from 10.3.0 to 10.4.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/10.3.0...10.4.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-03 15:15:17 +02:00
github-actions
a6ad088183 📝 Update release notes 2024-09-02 19:54:19 +00:00
Sofie Van Landeghem
b63b4189ee 💚 Set include-hidden-files to True when using the upload-artifact GH action (#12118)
* include-hidden-files when uploading coverage files

* include-hidden-files when building docs
2024-09-02 21:53:53 +02:00
github-actions
17f1f7b5bd 📝 Update release notes 2024-09-02 19:37:19 +00:00
dependabot[bot]
92bdfbc7ba ⬆ Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 (#12112)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-02 21:36:52 +02:00
github-actions
b203d7a15f 📝 Update release notes 2024-09-01 19:39:46 +00:00
Sebastián Ramírez
23bda0ffeb ♻️ Refactor internal check_file_field(), rename to ensure_multipart_is_installed() to clarify its purpose (#12106) 2024-09-01 21:39:25 +02:00
github-actions
d5c6cf8122 📝 Update release notes 2024-08-31 23:46:26 +00:00
Sebastián Ramírez
d08b95ea57 ♻️ Rename internal create_response_field() to create_model_field() as it's used for more than response models (#12103) 2024-09-01 01:46:03 +02:00
github-actions
3660c7a063 📝 Update release notes 2024-08-31 20:52:29 +00:00
Sebastián Ramírez
5b7fa3900e ♻️ Refactor and simplify internal data from solve_dependencies() using dataclasses (#12100) 2024-08-31 22:52:06 +02:00
github-actions
8d7d89e8c6 📝 Update release notes 2024-08-31 20:28:07 +00:00
Sebastián Ramírez
08547e1d57 ♻️ Refactor and simplify internal analyze_param() to structure data with dataclasses instead of tuple (#12099) 2024-08-31 22:27:44 +02:00
github-actions
75c4e7fc44 📝 Update release notes 2024-08-31 20:19:51 +00:00
Sebastián Ramírez
581aacc4a9 ♻️ Refactor and simplify dependencies data structures with dataclasses (#12098) 2024-08-31 22:19:30 +02:00
github-actions
47b3351be9 📝 Update release notes 2024-08-31 15:36:24 +00:00
Sebastián Ramírez
eebc6c3d54 🔧 Update sponsors link: Coherence (#12097) 2024-08-31 17:35:58 +02:00
github-actions
83422b1923 📝 Update release notes 2024-08-31 10:20:40 +00:00
Sebastián Ramírez
0077af9719 🔧 Update labeler config to handle sponsorships data (#12096) 2024-08-31 12:18:37 +02:00
github-actions
6c8a205db1 📝 Update release notes 2024-08-31 10:16:12 +00:00
Sebastián Ramírez
c37f2c976d 📝 Add note about time.perf_counter() in middlewares (#12095) 2024-08-31 10:15:50 +00:00
github-actions
5827b922c3 📝 Update release notes 2024-08-31 03:23:14 +00:00
Esteban Maya
1b5984b23b Merge pull request #11957 from domdent/docs/edit-timer-in-middleware
📝 Tweak middleware code sample `time.time()` to `time.perf_counter()`
2024-08-30 22:22:52 -05:00
Esteban Maya
6ca7b8c608 Merge branch 'master' into docs/edit-timer-in-middleware 2024-08-30 22:11:25 -05:00
github-actions
a2458d594f 📝 Update release notes 2024-08-30 16:20:42 +00:00
Sebastián Ramírez
9519380764 🔧 Update sponsors: Coherence (#12093) 2024-08-30 18:20:21 +02:00
github-actions
4eec14fa8c 📝 Update release notes 2024-08-30 16:01:05 +00:00
Marcin Sulikowski
6e98249c21 📝 Fix async test example not to trigger DeprecationWarning (#12084) 2024-08-30 18:00:41 +02:00
github-actions
17a29149e4 📝 Update release notes 2024-08-29 00:02:01 +00:00
Sebastián Ramírez
4cf3421178 🔧 Update sponsors, remove Kong (#12085) 2024-08-29 02:01:29 +02:00
github-actions
ffa6d2eafd 📝 Update release notes 2024-08-28 23:44:01 +00:00
Sofie Van Landeghem
ae27540348 🌐 Add Dutch translation for docs/nl/docs/index.md (#12042)
Co-authored-by: Max Scheijen <maxscheijen@gmail.com>
2024-08-29 01:41:46 +02:00
github-actions
3332895251 📝 Update release notes 2024-08-28 23:40:13 +00:00
Muhammad Ashiq Ameer
9b35d355bf 📝 Update docs_src/path_params_numeric_validations/tutorial006.py (#11478)
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2024-08-28 18:39:15 -05:00
github-actions
a930128910 📝 Update release notes 2024-08-28 23:35:03 +00:00
Alec Gillis
cabed9efb6 📝 Update comma in docs/en/docs/async.md (#12062)
Co-authored-by: Alec Gillis <alecgillis@quorum.us>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2024-08-28 18:33:37 -05:00
github-actions
48bf0db58f 📝 Update release notes 2024-08-28 14:07:23 +00:00
pre-commit-ci[bot]
4909e44a7f ⬆ [pre-commit.ci] pre-commit autoupdate (#12076)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-28 09:07:00 -05:00
github-actions
be9abcf353 📝 Update release notes 2024-08-28 13:48:40 +00:00
lkw123
f41f6234af 🌐 Update Chinese translation for docs/zh/docs/how-to/index.md (#12070) 2024-08-28 08:48:13 -05:00
github-actions
9416e89bd7 📝 Update release notes 2024-08-26 02:15:38 +00:00
Sebastián Ramírez
5fdbeed792 👷 Update latest-changes GitHub Action (#12073) 2024-08-26 02:14:56 +00:00
github-actions
3a96938771 📝 Update release notes 2024-08-25 02:44:27 +00:00
Sebastián Ramírez
bd1b77548f 📝 Update docs about serving FastAPI: ASGI servers, Docker containers, etc. (#12069) 2024-08-25 02:44:06 +00:00
github-actions
b5cbff9521 📝 Update release notes 2024-08-25 00:01:26 +00:00
Sebastián Ramírez
c692176d42 📝 Clarify response_class parameter, validations, and returning a response directly (#12067) 2024-08-24 19:01:04 -05:00
github-actions
d8e526c1db 📝 Update release notes 2024-08-24 21:52:29 +00:00
Sofie Van Landeghem
6aa44a85a2 📝 Fix minor typos and issues in the documentation (#12063) 2024-08-24 16:52:09 -05:00
github-actions
e4727ed20a 📝 Update release notes 2024-08-24 20:04:51 +00:00
GPla
9656895b60 📝 Add note in Docker docs about ensuring graceful shutdowns and lifespan events with CMD exec form (#11960)
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-24 20:04:30 +00:00
Sebastián Ramírez
d00af00d3f 🔖 Release version 0.112.2 2024-08-24 14:34:50 -05:00
github-actions
b69a9f3b6f 📝 Update release notes 2024-08-24 19:27:59 +00:00
Giunio
51b625e127 🐛 Fix allow_inf_nan option for Param and Body classes (#11867)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
2024-08-24 14:27:37 -05:00
github-actions
48b36f26d8 📝 Update release notes 2024-08-24 19:10:14 +00:00
Pastukhov Nikita
3a4ac24675 🐛 Ensure that app.include_router merges nested lifespans (#9630)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-24 14:09:52 -05:00
Sebastián Ramírez
22bf988dfb 📝 Update release notes 2024-08-23 22:48:20 -05:00
github-actions
6935fe8d38 📝 Update release notes 2024-08-24 03:16:48 +00:00
Aymen
8f03716757 📝 Fix a typo in virtual environement page (#12064) 2024-08-23 22:16:23 -05:00
Esteban Maya
866c6987fc Merge branch 'master' into docs/edit-timer-in-middleware 2024-08-22 12:55:06 -05:00
github-actions
d0ce9d2bdf 📝 Update release notes 2024-08-22 00:47:57 +00:00
Sebastián Ramírez
705659bb22 📝 Add docs about Environment Variables and Virtual Environments (#12054) 2024-08-21 19:47:31 -05:00
github-actions
4f3381a95e 📝 Update release notes 2024-08-21 16:58:20 +00:00
João Pedro Pereira Holanda
38ff43b690 🌐 Add Portuguese translation for docs/pt/docs/tutorial/request_file.md (#12018) 2024-08-21 11:56:50 -05:00
github-actions
2fe05762b2 📝 Update release notes 2024-08-21 16:55:38 +00:00
Yuki Watanabe
34e6e63fb2 🌐 Add Japanese translation for docs/ja/docs/learn/index.md (#11592) 2024-08-21 11:55:16 -05:00
github-actions
2d34086b70 📝 Update release notes 2024-08-20 00:40:55 +00:00
pre-commit-ci[bot]
f4dfbae903 ⬆ [pre-commit.ci] pre-commit autoupdate (#12046)
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.6.0)
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-19 19:40:31 -05:00
github-actions
e8322228b4 📝 Update release notes 2024-08-19 18:15:49 +00:00
Alejandra
6ba8407ff3 📝 Update Spanish translation docs for consistency (#12044) 2024-08-19 13:15:21 -05:00
github-actions
63ae0f1070 📝 Update release notes 2024-08-19 17:35:25 +00:00
xuvjso
f0866bc205 🌐 Update docs about dependencies with yield (#12028) 2024-08-19 12:35:03 -05:00
github-actions
ae97785ded 📝 Update release notes 2024-08-18 23:26:36 +00:00
Sebastián Ramírez
bcd737de33 📝 Add Asyncer mention in async docs (#12037) 2024-08-18 23:26:14 +00:00
github-actions
98712b9e09 📝 Update release notes 2024-08-18 23:17:21 +00:00
Sebastián Ramírez
0e77481acf 📝 Move the Features docs to the top level to improve the main page menu (#12036) 2024-08-18 18:16:56 -05:00
github-actions
6ebaf0efcb 📝 Update release notes 2024-08-18 21:08:39 +00:00
Sebastián Ramírez
4f1eb0cd9e 🔧 Update coverage config files (#12035) 2024-08-18 16:07:03 -05:00
github-actions
0da0814d8a 📝 Update release notes 2024-08-17 21:20:52 +00:00
Sebastián Ramírez
9bfc48ad9f 📝 Update FastAPI People, do not translate to have the most recent info (#12034) 2024-08-17 16:20:31 -05:00
github-actions
882f77f925 📝 Update release notes 2024-08-17 06:54:13 +00:00
0shah0
85cded53c8 ✏️ Fix import typo in reference example for Security (#11168)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-17 06:53:52 +00:00
github-actions
066ea10ac5 📝 Update release notes 2024-08-17 06:42:28 +00:00
Ahsan Sheraz
ff1118d6a0 🌐 Update Urdu translation for docs/ur/docs/benchmarks.md (#10046)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-17 06:42:07 +00:00
github-actions
6aa0435a3e 📝 Update release notes 2024-08-17 04:52:53 +00:00
Jamie Phan
659350e9cd 🎨 Fix typing annotation for semi-internal FastAPI.add_api_route() (#10240)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-17 04:52:31 +00:00
github-actions
980c88c347 📝 Update release notes 2024-08-17 04:14:10 +00:00
Sebastián Ramírez
3a3ad5d66d ⬆️ Upgrade version of Ruff and reformat (#12032)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-16 23:13:50 -05:00
github-actions
6433c3b70e 📝 Update release notes 2024-08-17 04:00:12 +00:00
gitworkflows
4a7f6e0ae6 🔨 Standardize shebang across shell scripts (#11942) 2024-08-16 22:59:06 -05:00
github-actions
263e46e540 📝 Update release notes 2024-08-17 03:57:45 +00:00
Sofie Van Landeghem
957d747d21 📝 Highlight correct line in tutorial docs/en/docs/tutorial/body-multiple-params.md (#11978)
Co-authored-by: Esteban Maya <emayacadavid9@gmail.com>
2024-08-16 22:57:21 -05:00
github-actions
8b05d4518b 📝 Update release notes 2024-08-16 23:18:21 +00:00
Alejandra
8a146b7a28 🔥 Remove Sentry link from Advanced Middleware docs (#12031) 2024-08-16 18:18:02 -05:00
github-actions
beedc72281 📝 Update release notes 2024-08-16 22:32:33 +00:00
Esteban Maya
8c85b8f4aa Merge pull request #11979 from fastapi/dependabot/pip/sqlalchemy-gte-1.3.18-and-lt-2.0.33
⬆ Update sqlalchemy requirement from <1.4.43,>=1.3.18 to >=1.3.18,<2.0.33
2024-08-16 17:32:10 -05:00
Esteban Maya
9c9cccef0c Merge branch 'master' into dependabot/pip/sqlalchemy-gte-1.3.18-and-lt-2.0.33 2024-08-16 17:21:47 -05:00
github-actions
7ed9a4971e 📝 Update release notes 2024-08-16 21:56:54 +00:00
Sebastián Ramírez
daf4970ed7 📝 Clarify management tasks for translations, multiples files in one PR (#12030) 2024-08-16 21:56:33 +00:00
dependabot[bot]
be7e7d4433 ⬆ Update sqlalchemy requirement
---
updated-dependencies:
- dependency-name: sqlalchemy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-16 17:45:47 +00:00
github-actions
29babdc0a1 📝 Update release notes 2024-08-16 17:44:48 +00:00
Sebastián Ramírez
46412ff67d 🔊 Remove old ignore warnings (#11950) 2024-08-16 17:44:28 +00:00
github-actions
2e0f74f58b 📝 Update release notes 2024-08-16 17:29:43 +00:00
Sebastián Ramírez
ff8fcd3b44 ⬆️ Upgrade griffe-typingdoc for the docs (#12029) 2024-08-16 17:29:21 +00:00
github-actions
9a939dec47 📝 Update release notes 2024-08-16 16:56:43 +00:00
gitworkflows
f79247b4e5 🙈 Add .coverage* to .gitignore (#11940) 2024-08-16 11:56:19 -05:00
github-actions
46d0ffc0d7 📝 Update release notes 2024-08-16 16:52:46 +00:00
VaitoSoi
fd5c00ab76 📝 Edit the link to the OpenAPI "Responses Object" and "Response Object" sections in the "Additional Responses in OpenAPI" section (#11996)
Co-authored-by: svlandeg <svlandeg@github.com>
2024-08-16 11:51:25 -05:00
github-actions
9f78e08c14 📝 Update release notes 2024-08-16 16:50:25 +00:00
Jiri Kuncar
c81f575d0d 🔨 Specify email-validator dependency with dash (#11515)
Co-authored-by: svlandeg <svlandeg@github.com>
2024-08-16 11:50:01 -05:00
github-actions
a3f42718de 📝 Update release notes 2024-08-16 02:05:14 +00:00
Alejandra
10eee5c3b3 🌐 Add Spanish translation for docs/es/docs/project-generation.md (#11947)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-16 02:04:50 +00:00
github-actions
a51a98b07e 📝 Update release notes 2024-08-16 01:58:02 +00:00
Sławomir Ehlert
0aaaed581e ⚙️ Record and show test coverage contexts (what test covers which line) (#11518)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-15 20:57:38 -05:00
github-actions
e8f7bf0ad5 📝 Update release notes 2024-08-16 00:05:21 +00:00
Micael Jarniac
a0c529ef0a 📝 Fix minor typo (#12026) 2024-08-15 19:04:55 -05:00
github-actions
470f1ae57d 📝 Update release notes 2024-08-15 23:30:36 +00:00
Nils Lindemann
8809b3685f 📝 Several docs improvements, tweaks, and clarifications (#11390)
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-15 23:30:12 +00:00
github-actions
3c8d0abc87 📝 Update release notes 2024-08-15 22:38:22 +00:00
Jun-Ah 준아
265dbeb663 📝 Add missing compresslevel parameter on docs for GZipMiddleware (#11350)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-15 17:38:02 -05:00
github-actions
4636c621a9 📝 Update release notes 2024-08-15 22:31:36 +00:00
Luke Okomilo
2cb1333b97 📝 Fix inconsistent response code when item already exists in docs for testing (#11818)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-15 22:31:16 +00:00
github-actions
366bdebd9e 📝 Update release notes 2024-08-15 21:30:26 +00:00
Cedric L'homme
86c8f4fc2b 📝 Update docs/en/docs/tutorial/body.md with Python 3.10 union type example (#11415)
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2024-08-15 16:29:58 -05:00
Sebastián Ramírez
ead4f8c6a4 Merge branch 'master' into docs/edit-timer-in-middleware 2024-08-07 16:08:05 -05:00
Dom
7ff5da8bf2 edit middleware docs code sample to use perf_counter as a timer 2024-08-06 14:46:39 +01:00
813 changed files with 21449 additions and 14645 deletions

View File

@@ -515,9 +515,9 @@ def get_individual_sponsors(settings: Settings):
tiers: DefaultDict[float, Dict[str, SponsorEntity]] = defaultdict(dict)
for node in nodes:
tiers[node.tier.monthlyPriceInDollars][
node.sponsorEntity.login
] = node.sponsorEntity
tiers[node.tier.monthlyPriceInDollars][node.sponsorEntity.login] = (
node.sponsorEntity
)
return tiers

4
.github/labeler.yml vendored
View File

@@ -7,6 +7,8 @@ docs:
- all-globs-to-all-files:
- '!fastapi/**'
- '!pyproject.toml'
- '!docs/en/data/sponsors.yml'
- '!docs/en/overrides/main.html'
lang-all:
- all:
@@ -28,6 +30,8 @@ internal:
- .pre-commit-config.yaml
- pdm_build.py
- requirements*.txt
- docs/en/data/sponsors.yml
- docs/en/overrides/main.html
- all-globs-to-all-files:
- '!docs/*/docs/**'
- '!fastapi/**'

View File

@@ -113,6 +113,7 @@ jobs:
with:
name: docs-site-${{ matrix.lang }}
path: ./site/**
include-hidden-files: true
# https://github.com/marketplace/actions/alls-green#why
docs-all-green: # This job does nothing and is only used for the branch protection

View File

@@ -55,19 +55,19 @@ jobs:
# hashFiles returns an empty string if there are no files
if: hashFiles('./site/*')
id: deploy
uses: cloudflare/pages-action@v1
env:
PROJECT_NAME: fastapitiangolo
BRANCH: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: fastapitiangolo
directory: './site'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
command: pages deploy ./site --project-name=${{ env.PROJECT_NAME }} --branch=${{ env.BRANCH }}
- name: Comment Deploy
run: python ./scripts/deploy_docs_status.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEPLOY_URL: ${{ steps.deploy.outputs.url }}
DEPLOY_URL: ${{ steps.deploy.outputs.deployment-url }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_ID: ${{ github.run_id }}
IS_DONE: "true"

View File

@@ -2,7 +2,7 @@ name: Issue Manager
on:
schedule:
- cron: "10 3 * * *"
- cron: "13 22 * * *"
issue_comment:
types:
- created
@@ -16,6 +16,7 @@ on:
permissions:
issues: write
pull-requests: write
jobs:
issue-manager:
@@ -26,7 +27,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: tiangolo/issue-manager@0.5.0
- uses: tiangolo/issue-manager@0.5.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
config: >
@@ -35,8 +36,8 @@ jobs:
"delay": 864000,
"message": "Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs."
},
"changes-requested": {
"waiting": {
"delay": 2628000,
"message": "As this PR had requested changes to be applied but has been inactive for a while, it's now going to be closed. But if there's anyone interested, feel free to create a new PR."
"message": "As this PR has been waiting for the original user for a while but seems to be inactive, it's now going to be closed. But if there's anyone interested, feel free to create a new PR."
}
}

View File

@@ -17,6 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
if: ${{ github.event.action != 'labeled' && github.event.action != 'unlabeled' }}
- run: echo "Done adding labels"
# Run this after labeler applied labels
check-labels:
needs:

View File

@@ -34,8 +34,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- uses: docker://tiangolo/latest-changes:0.3.0
# - uses: tiangolo/latest-changes@main
- uses: tiangolo/latest-changes@0.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest_changes_file: docs/en/docs/release-notes.md

View File

@@ -35,7 +35,7 @@ jobs:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.9.0
uses: pypa/gh-action-pypi-publish@v1.10.3
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

View File

@@ -37,7 +37,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
- name: Install Pydantic v2
run: pip install "pydantic>=2.0.2,<3.0.0"
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
- name: Lint
run: bash scripts/lint.sh
@@ -79,7 +79,7 @@ jobs:
run: pip install "pydantic>=1.10.0,<2.0.0"
- name: Install Pydantic v2
if: matrix.pydantic-version == 'pydantic-v2'
run: pip install "pydantic>=2.0.2,<3.0.0"
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
- run: mkdir coverage
- name: Test
run: bash scripts/test.sh
@@ -91,6 +91,7 @@ jobs:
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: coverage
include-hidden-files: true
coverage-combine:
needs: [test]
@@ -117,12 +118,13 @@ jobs:
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}"
- run: coverage html --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
include-hidden-files: true
# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection

2
.gitignore vendored
View File

@@ -7,7 +7,7 @@ __pycache__
htmlcov
dist
site
.coverage
.coverage*
coverage.xml
.netlify
test.db

View File

@@ -4,7 +4,7 @@ default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-toml
@@ -13,8 +13,8 @@ repos:
- --unsafe
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.2.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args:

View File

@@ -52,11 +52,9 @@ The key features are:
<a href="https://bump.sh/fastapi?utm_source=fastapi&utm_medium=referral&utm_campaign=sponsor" target="_blank" title="Automate FastAPI documentation generation with Bump.sh"><img src="https://fastapi.tiangolo.com/img/sponsors/bump-sh.svg"></a>
<a href="https://github.com/scalar/scalar/?utm_source=fastapi&utm_medium=website&utm_campaign=main-badge" target="_blank" title="Scalar: Beautiful Open-Source API References from Swagger/OpenAPI files"><img src="https://fastapi.tiangolo.com/img/sponsors/scalar.svg"></a>
<a href="https://www.propelauth.com/?utm_source=fastapi&utm_campaign=1223&utm_medium=mainbadge" target="_blank" title="Auth, user management and more for your B2B product"><img src="https://fastapi.tiangolo.com/img/sponsors/propelauth.png"></a>
<a href="https://docs.withcoherence.com/configuration/frameworks/?utm_medium=advertising&utm_source=fastapi&utm_campaign=docs#fastapi-example" target="_blank" title="Coherence"><img src="https://fastapi.tiangolo.com/img/sponsors/coherence.png"></a>
<a href="https://www.withcoherence.com/?utm_medium=advertising&utm_source=fastapi&utm_campaign=website" target="_blank" title="Coherence"><img src="https://fastapi.tiangolo.com/img/sponsors/coherence.png"></a>
<a href="https://www.mongodb.com/developer/languages/python/python-quickstart-fastapi/?utm_campaign=fastapi_framework&utm_source=fastapi_sponsorship&utm_medium=web_referral" target="_blank" title="Simplify Full Stack Development with FastAPI & MongoDB"><img src="https://fastapi.tiangolo.com/img/sponsors/mongodb.png"></a>
<a href="https://konghq.com/products/kong-konnect?utm_medium=referral&utm_source=github&utm_campaign=platform&utm_content=fast-api" target="_blank" title="Kong Konnect - API management platform"><img src="https://fastapi.tiangolo.com/img/sponsors/kong.png"></a>
<a href="https://zuplo.link/fastapi-gh" target="_blank" title="Zuplo: Scale, Protect, Document, and Monetize your FastAPI"><img src="https://fastapi.tiangolo.com/img/sponsors/zuplo.png"></a>
<a href="https://fine.dev?ref=fastapibadge" target="_blank" title="Fine's AI FastAPI Workflow: Effortlessly Deploy and Integrate FastAPI into Your Project"><img src="https://fastapi.tiangolo.com/img/sponsors/fine.png"></a>
<a href="https://liblab.com?utm_source=fastapi" target="_blank" title="liblab - Generate SDKs from FastAPI"><img src="https://fastapi.tiangolo.com/img/sponsors/liblab.png"></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://databento.com/" target="_blank" title="Pay as you go for market data"><img src="https://fastapi.tiangolo.com/img/sponsors/databento.svg"></a>
@@ -132,6 +130,8 @@ FastAPI stands on the shoulders of giants:
## Installation
Create and activate a <a href="https://fastapi.tiangolo.com/virtual-environments/" class="external-link" target="_blank">virtual environment</a> and then install FastAPI:
<div class="termy">
```console
@@ -392,7 +392,7 @@ Coming back to the previous code example, **FastAPI** will:
* 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:
* 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.
@@ -462,7 +462,7 @@ When you install FastAPI with `pip install "fastapi[standard]"` it comes the `st
Used by Pydantic:
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - for email validation.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email-validator</code></a> - for email validation.
Used by Starlette:

View File

@@ -1,185 +0,0 @@
---
hide:
- navigation
---
# FastAPI İnsanlar
FastAPI-ın bütün mənşəli insanları qəbul edən heyrətamiz icması var.
## Yaradıcı - İcraçı
Salam! 👋
Bu mənəm:
{% 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">Cavablar: {{ user.answers }}</div><div class="count">Pull Request-lər: {{ user.prs }}</div></div>
{% endfor %}
</div>
{% endif %}
Mən **FastAPI**-ın yaradıcısı və icraçısıyam. Əlavə məlumat almaq üçün [Yardım FastAPI - Yardım alın - Müəlliflə əlaqə qurun](help-fastapi.md#connect-with-the-author){.internal-link target=_blank} səhifəsinə baxa bilərsiniz.
...Burada isə sizə icmanı göstərmək istəyirəm.
---
**FastAPI** icmadan çoxlu dəstək alır və mən onların əməyini vurğulamaq istəyirəm.
Bu insanlar:
* [GitHub-da başqalarının suallarına kömək edirlər](help-fastapi.md#help-others-with-questions-in-github){.internal-link target=_blank}.
* [Pull Request-lər yaradırlar](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}.
* Pull Request-ləri ([xüsusilə tərcümələr üçün vacib olan](contributing.md#translations){.internal-link target=_blank}.) nəzərdən keçirirlər.
Bu insanlara təşəkkür edirəm. 👏 🙇
## Keçən ayın ən fəal istifadəçiləri
Bu istifadəçilər keçən ay [GitHub-da başqalarının suallarına](help-fastapi.md#help-others-with-questions-in-github){.internal-link target=_blank} ən çox kömək edənlərdir. ☕
{% if people %}
<div class="user-list user-list-center">
{% for user in people.last_month_experts[:10] %}
<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">Cavablandırılmış suallar: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## Mütəxəssislər
Burada **FastAPI Mütəxəssisləri** var. 🤓
Bu istifadəçilər indiyə qədər [GitHub-da başqalarının suallarına](help-fastapi.md#help-others-with-questions-in-github){.internal-link target=_blank} ən çox kömək edənlərdir.
Onlar bir çox insanlara kömək edərək mütəxəssis olduqlarını sübut ediblər. ✨
{% if people %}
<div class="user-list user-list-center">
{% for user in people.experts[:50] %}
<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">Cavablandırılmış suallar: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## Ən yaxşı əməkdaşlar
Burada **Ən yaxşı əməkdaşlar** var. 👷
Bu istifadəçilərin ən çox *birləşdirilmiş* [Pull Request-ləri var](help-fastapi.md#create-a-pull-request){.internal-link target=_blank}.
Onlar mənbə kodu, sənədləmə, tərcümələr və s. barədə əmək göstərmişlər. 📦
{% if people %}
<div class="user-list user-list-center">
{% for user in people.top_contributors[:50] %}
<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">Pull Request-lər: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
Bundan başqa bir neçə (yüzdən çox) əməkdaş var ki, onları <a href="https://github.com/fastapi/fastapi/graphs/contributors" class="external-link" target="_blank">FastAPI GitHub Əməkdaşlar səhifəsində</a> görə bilərsiniz. 👷
## Ən çox rəy verənlər
Bu istifadəçilər **ən çox rəy verənlər**dir.
### Tərcümələr üçün rəylər
Mən yalnız bir neçə dildə danışıram (və çox da yaxşı deyil 😅). Bu səbəbdən, rəy verənlər sənədlərin [**tərcümələrini təsdiqləmək üçün gücə malik olanlar**](contributing.md#translations){.internal-link target=_blank}dır. Onlar olmadan, bir çox dilə tərcümə olunmuş sənədlər olmazdı.
---
Başqalarının Pull Request-lərinə **Ən çox rəy verənlər** 🕵️ kodun, sənədlərin və xüsusilə də **tərcümələrin** keyfiyyətini təmin edirlər.
{% if people %}
<div class="user-list user-list-center">
{% for user in people.top_translations_reviewers[:50] %}
<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">Rəylər: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## Sponsorlar
Bunlar **Sponsorlar**dır. 😎
Onlar mənim **FastAPI** (və digər) işlərimi əsasən <a href="https://github.com/sponsors/tiangolo" class="external-link" target="_blank">GitHub Sponsorlar</a> vasitəsilə dəstəkləyirlər.
{% if sponsors %}
{% if sponsors.gold %}
### Qızıl Sponsorlar
{% 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 %}
### Gümüş Sponsorlar
{% 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 %}
### Bürünc Sponsorlar
{% 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 %}
### Fərdi Sponsorlar
{% 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 %}
## Məlumatlar haqqında - texniki detallar
Bu səhifənin əsas məqsədi, icmanın başqalarına kömək etmək üçün göstərdiyi əməyi vurğulamaqdır.
Xüsusilə də normalda daha az görünən və bir çox hallarda daha çətin olan, başqalarının suallarına kömək etmək və tərcümələrlə bağlı Pull Request-lərə rəy vermək kimi səy göstərmək.
Bu səhifənin məlumatları hər ay hesablanır və siz <a href="https://github.com/fastapi/fastapi/blob/master/.github/actions/people/app/main.py" class="external-link" target="_blank">buradan mənbə kodunu</a> oxuya bilərsiniz.
Burada sponsorların əməyini də vurğulamaq istəyirəm.
Mən həmçinin alqoritmi, bölmələri, eşikləri və s. yeniləmək hüququnu da qoruyuram (hər ehtimala qarşı 🤷).

View File

@@ -442,7 +442,7 @@ Müstəqil TechEmpower meyarları göstərir ki, Uvicorn üzərində işləyən
Pydantic tərəfindən istifadə olunanlar:
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - e-poçtun yoxlanılması üçün.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email-validator</code></a> - e-poçtun yoxlanılması üçün.
* <a href="https://docs.pydantic.dev/latest/usage/pydantic_settings/" target="_blank"><code>pydantic-settings</code></a> - parametrlərin idarə edilməsi üçün.
* <a href="https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/" target="_blank"><code>pydantic-extra-types</code></a> - Pydantic ilə istifadə edilə bilən əlavə tiplər üçün.

View File

@@ -439,7 +439,7 @@ item: Item
Pydantic দ্বারা ব্যবহৃত:
- <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - ইমেল যাচাইকরণের জন্য।
- <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email-validator</code></a> - ইমেল যাচাইকরণের জন্য।
স্টারলেট দ্বারা ব্যবহৃত:

View File

@@ -23,7 +23,7 @@ Python-এ ঐচ্ছিক "টাইপ হিন্ট" (যা "টাই
চলুন একটি সাধারণ উদাহরণ দিয়ে শুরু করি:
```Python
{!../../../docs_src/python_types/tutorial001.py!}
{!../../docs_src/python_types/tutorial001.py!}
```
এই প্রোগ্রামটি কল করলে আউটপুট হয়:
@@ -39,7 +39,7 @@ John Doe
* তাদেরকে মাঝখানে একটি স্পেস দিয়ে <abbr title="একটার পরে একটা একত্রিত করা">concatenate</abbr> করে।
```Python hl_lines="2"
{!../../../docs_src/python_types/tutorial001.py!}
{!../../docs_src/python_types/tutorial001.py!}
```
### এটি সম্পাদনা করুন
@@ -83,7 +83,7 @@ John Doe
এগুলিই "টাইপ হিন্ট":
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial002.py!}
{!../../docs_src/python_types/tutorial002.py!}
```
এটি ডিফল্ট ভ্যালু ঘোষণা করার মত নয় যেমন:
@@ -113,7 +113,7 @@ John Doe
এই ফাংশনটি দেখুন, এটিতে ইতিমধ্যে টাইপ হিন্ট রয়েছে:
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial003.py!}
{!../../docs_src/python_types/tutorial003.py!}
```
এডিটর ভেরিয়েবলগুলির টাইপ জানার কারণে, আপনি শুধুমাত্র অটোকমপ্লিশনই পান না, আপনি এরর চেকও পান:
@@ -123,7 +123,7 @@ John Doe
এখন আপনি জানেন যে আপনাকে এটি ঠিক করতে হবে, `age`-কে একটি স্ট্রিং হিসেবে রূপান্তর করতে `str(age)` ব্যবহার করতে হবে:
```Python hl_lines="2"
{!../../../docs_src/python_types/tutorial004.py!}
{!../../docs_src/python_types/tutorial004.py!}
```
## টাইপ ঘোষণা
@@ -144,7 +144,7 @@ John Doe
* `bytes`
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial005.py!}
{!../../docs_src/python_types/tutorial005.py!}
```
### টাইপ প্যারামিটার সহ জেনেরিক টাইপ
@@ -182,7 +182,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
যেহেতু লিস্ট এমন একটি টাইপ যা অভ্যন্তরীণ টাইপগুলি ধারণ করে, আপনি তাদের স্কোয়ার ব্রাকেটের ভিতরে ব্যবহার করুন:
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial006_py39.py!}
{!> ../../docs_src/python_types/tutorial006_py39.py!}
```
////
@@ -192,7 +192,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
`typing` থেকে `List` (বড় হাতের `L` দিয়ে) ইমপোর্ট করুন:
``` Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial006.py!}
{!> ../../docs_src/python_types/tutorial006.py!}
```
ভেরিয়েবলটি ঘোষণা করুন, একই কোলন (`:`) সিনট্যাক্স ব্যবহার করে।
@@ -202,7 +202,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
যেহেতু লিস্ট এমন একটি টাইপ যা অভ্যন্তরীণ টাইপগুলি ধারণ করে, আপনি তাদের স্কোয়ার ব্রাকেটের ভিতরে করুন:
```Python hl_lines="4"
{!> ../../../docs_src/python_types/tutorial006.py!}
{!> ../../docs_src/python_types/tutorial006.py!}
```
////
@@ -240,7 +240,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
//// tab | Python 3.9+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial007_py39.py!}
{!> ../../docs_src/python_types/tutorial007_py39.py!}
```
////
@@ -248,7 +248,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
{!> ../../docs_src/python_types/tutorial007.py!}
```
////
@@ -269,7 +269,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
//// tab | Python 3.9+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial008_py39.py!}
{!> ../../docs_src/python_types/tutorial008_py39.py!}
```
////
@@ -277,7 +277,7 @@ Python যত এগিয়ে যাচ্ছে, **নতুন সংস্
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
{!> ../../docs_src/python_types/tutorial008.py!}
```
////
@@ -299,7 +299,7 @@ Python 3.10-এ একটি **নতুন সিনট্যাক্স** আ
//// tab | Python 3.10+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial008b_py310.py!}
{!> ../../docs_src/python_types/tutorial008b_py310.py!}
```
////
@@ -307,7 +307,7 @@ Python 3.10-এ একটি **নতুন সিনট্যাক্স** আ
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
{!> ../../docs_src/python_types/tutorial008b.py!}
```
////
@@ -321,7 +321,7 @@ Python 3.10-এ একটি **নতুন সিনট্যাক্স** আ
Python 3.6 এবং তার উপরের সংস্করণগুলিতে (Python 3.10 অনতর্ভুক্ত) আপনি `typing` মডিউল থেকে `Optional` ইমপোর্ট করে এটি ঘোষণা এবং ব্যবহার করতে পারেন।
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009.py!}
{!../../docs_src/python_types/tutorial009.py!}
```
`Optional[str]` ব্যবহার করা মানে হল শুধু `str` নয়, এটি হতে পারে `None`-ও, যা আপনার এডিটরকে সেই ত্রুটিগুলি শনাক্ত করতে সাহায্য করবে যেখানে আপনি ধরে নিচ্ছেন যে একটি মান সবসময় `str` হবে, অথচ এটি `None`-ও হতে পারেও।
@@ -333,7 +333,7 @@ Python 3.6 এবং তার উপরের সংস্করণগুলি
//// tab | Python 3.10+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial009_py310.py!}
{!> ../../docs_src/python_types/tutorial009_py310.py!}
```
////
@@ -341,7 +341,7 @@ Python 3.6 এবং তার উপরের সংস্করণগুলি
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
{!> ../../docs_src/python_types/tutorial009.py!}
```
////
@@ -349,7 +349,7 @@ Python 3.6 এবং তার উপরের সংস্করণগুলি
//// tab | Python 3.8+ বিকল্প
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
{!> ../../docs_src/python_types/tutorial009b.py!}
```
////
@@ -370,7 +370,7 @@ Python 3.6 এবং তার উপরের সংস্করণগুলি
একটি উদাহরণ হিসেবে, এই ফাংশনটি নিন:
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009c.py!}
{!../../docs_src/python_types/tutorial009c.py!}
```
`name` প্যারামিটারটি `Optional[str]` হিসেবে সংজ্ঞায়িত হয়েছে, কিন্তু এটি **অপশনাল নয়**, আপনি প্যারামিটার ছাড়া ফাংশনটি কল করতে পারবেন না:
@@ -388,7 +388,7 @@ say_hi(name=None) # এটি কাজ করে, None বৈধ 🎉
সুখবর হল, একবার আপনি Python 3.10 ব্যবহার করা শুরু করলে, আপনাকে এগুলোর ব্যাপারে আর চিন্তা করতে হবে না, যেহুতু আপনি | ব্যবহার করেই ইউনিয়ন ঘোষণা করতে পারবেন:
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009c_py310.py!}
{!../../docs_src/python_types/tutorial009c_py310.py!}
```
এবং তারপর আপনাকে নামগুলি যেমন `Optional` এবং `Union` নিয়ে আর চিন্তা করতে হবে না। 😎
@@ -452,13 +452,13 @@ Python 3.10-এ, `Union` এবং `Optional` জেনেরিকস ব্য
ধরুন আপনার কাছে `Person` নামে একটি ক্লাস আছে, যার একটি নাম আছে:
```Python hl_lines="1-3"
{!../../../docs_src/python_types/tutorial010.py!}
{!../../docs_src/python_types/tutorial010.py!}
```
তারপর আপনি একটি ভেরিয়েবলকে `Person` টাইপের হিসেবে ঘোষণা করতে পারেন:
```Python hl_lines="6"
{!../../../docs_src/python_types/tutorial010.py!}
{!../../docs_src/python_types/tutorial010.py!}
```
এবং তারপর, আবার, আপনি এডিটর সাপোর্ট পেয়ে যাবেন:
@@ -486,7 +486,7 @@ Python 3.10-এ, `Union` এবং `Optional` জেনেরিকস ব্য
//// tab | Python 3.10+
```Python
{!> ../../../docs_src/python_types/tutorial011_py310.py!}
{!> ../../docs_src/python_types/tutorial011_py310.py!}
```
////
@@ -494,7 +494,7 @@ Python 3.10-এ, `Union` এবং `Optional` জেনেরিকস ব্য
//// tab | Python 3.9+
```Python
{!> ../../../docs_src/python_types/tutorial011_py39.py!}
{!> ../../docs_src/python_types/tutorial011_py39.py!}
```
////
@@ -502,7 +502,7 @@ Python 3.10-এ, `Union` এবং `Optional` জেনেরিকস ব্য
//// tab | Python 3.8+
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}
{!> ../../docs_src/python_types/tutorial011.py!}
```
////
@@ -532,7 +532,7 @@ Python-এ এমন একটি ফিচার আছে যা `Annotated`
Python 3.9-এ, `Annotated` স্ট্যান্ডার্ড লাইব্রেরিতে অন্তর্ভুক্ত, তাই আপনি এটি `typing` থেকে ইমপোর্ট করতে পারেন।
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial013_py39.py!}
{!> ../../docs_src/python_types/tutorial013_py39.py!}
```
////
@@ -544,7 +544,7 @@ Python 3.9-এর নীচের সংস্করণগুলিতে, আ
এটি **FastAPI** এর সাথে ইতিমদ্ধে ইনস্টল হয়ে থাকবে।
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial013.py!}
{!> ../../docs_src/python_types/tutorial013.py!}
```
////

View File

@@ -27,7 +27,7 @@ Jedes dieser Response-`dict`s kann einen Schlüssel `model` haben, welcher ein P
Um beispielsweise eine weitere Response mit dem Statuscode `404` und einem Pydantic-Modell `Message` zu deklarieren, können Sie schreiben:
```Python hl_lines="18 22"
{!../../../docs_src/additional_responses/tutorial001.py!}
{!../../docs_src/additional_responses/tutorial001.py!}
```
/// note | "Hinweis"
@@ -178,7 +178,7 @@ Sie können denselben `responses`-Parameter verwenden, um verschiedene Medientyp
Sie können beispielsweise einen zusätzlichen Medientyp `image/png` hinzufügen und damit deklarieren, dass Ihre *Pfadoperation* ein JSON-Objekt (mit dem Medientyp `application/json`) oder ein PNG-Bild zurückgeben kann:
```Python hl_lines="19-24 28"
{!../../../docs_src/additional_responses/tutorial002.py!}
{!../../docs_src/additional_responses/tutorial002.py!}
```
/// note | "Hinweis"
@@ -208,7 +208,7 @@ Sie können beispielsweise eine Response mit dem Statuscode `404` deklarieren, d
Und eine Response mit dem Statuscode `200`, die Ihr `response_model` verwendet, aber ein benutzerdefiniertes Beispiel (`example`) enthält:
```Python hl_lines="20-31"
{!../../../docs_src/additional_responses/tutorial003.py!}
{!../../docs_src/additional_responses/tutorial003.py!}
```
Es wird alles kombiniert und in Ihre OpenAPI eingebunden und in der API-Dokumentation angezeigt:
@@ -244,7 +244,7 @@ Mit dieser Technik können Sie einige vordefinierte Responses in Ihren *Pfadoper
Zum Beispiel:
```Python hl_lines="13-17 26"
{!../../../docs_src/additional_responses/tutorial004.py!}
{!../../docs_src/additional_responses/tutorial004.py!}
```
## Weitere Informationen zu OpenAPI-Responses

View File

@@ -17,7 +17,7 @@ Um dies zu erreichen, importieren Sie `JSONResponse`, und geben Sie Ihren Inhalt
//// tab | Python 3.10+
```Python hl_lines="4 25"
{!> ../../../docs_src/additional_status_codes/tutorial001_an_py310.py!}
{!> ../../docs_src/additional_status_codes/tutorial001_an_py310.py!}
```
////
@@ -25,7 +25,7 @@ Um dies zu erreichen, importieren Sie `JSONResponse`, und geben Sie Ihren Inhalt
//// tab | Python 3.9+
```Python hl_lines="4 25"
{!> ../../../docs_src/additional_status_codes/tutorial001_an_py39.py!}
{!> ../../docs_src/additional_status_codes/tutorial001_an_py39.py!}
```
////
@@ -33,7 +33,7 @@ Um dies zu erreichen, importieren Sie `JSONResponse`, und geben Sie Ihren Inhalt
//// tab | Python 3.8+
```Python hl_lines="4 26"
{!> ../../../docs_src/additional_status_codes/tutorial001_an.py!}
{!> ../../docs_src/additional_status_codes/tutorial001_an.py!}
```
////
@@ -47,7 +47,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="2 23"
{!> ../../../docs_src/additional_status_codes/tutorial001_py310.py!}
{!> ../../docs_src/additional_status_codes/tutorial001_py310.py!}
```
////
@@ -61,7 +61,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="4 25"
{!> ../../../docs_src/additional_status_codes/tutorial001.py!}
{!> ../../docs_src/additional_status_codes/tutorial001.py!}
```
////

View File

@@ -21,7 +21,7 @@ Dazu deklarieren wir eine Methode `__call__`:
//// tab | Python 3.9+
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
@@ -29,7 +29,7 @@ Dazu deklarieren wir eine Methode `__call__`:
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
@@ -43,7 +43,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/dependencies/tutorial011.py!}
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
@@ -57,7 +57,7 @@ Und jetzt können wir `__init__` verwenden, um die Parameter der Instanz zu dekl
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
@@ -65,7 +65,7 @@ Und jetzt können wir `__init__` verwenden, um die Parameter der Instanz zu dekl
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
@@ -79,7 +79,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/dependencies/tutorial011.py!}
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
@@ -93,7 +93,7 @@ Wir könnten eine Instanz dieser Klasse erstellen mit:
//// tab | Python 3.9+
```Python hl_lines="18"
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
@@ -101,7 +101,7 @@ Wir könnten eine Instanz dieser Klasse erstellen mit:
//// tab | Python 3.8+
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
@@ -115,7 +115,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="16"
{!> ../../../docs_src/dependencies/tutorial011.py!}
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////
@@ -137,7 +137,7 @@ checker(q="somequery")
//// tab | Python 3.9+
```Python hl_lines="22"
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial011_an_py39.py!}
```
////
@@ -145,7 +145,7 @@ checker(q="somequery")
//// tab | Python 3.8+
```Python hl_lines="21"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
{!> ../../docs_src/dependencies/tutorial011_an.py!}
```
////
@@ -159,7 +159,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial011.py!}
{!> ../../docs_src/dependencies/tutorial011.py!}
```
////

View File

@@ -33,13 +33,13 @@ Betrachten wir als einfaches Beispiel eine Dateistruktur ähnlich der in [Größ
Die Datei `main.py` hätte als Inhalt:
```Python
{!../../../docs_src/async_tests/main.py!}
{!../../docs_src/async_tests/main.py!}
```
Die Datei `test_main.py` hätte die Tests für `main.py`, das könnte jetzt so aussehen:
```Python
{!../../../docs_src/async_tests/test_main.py!}
{!../../docs_src/async_tests/test_main.py!}
```
## Es ausführen
@@ -61,7 +61,7 @@ $ pytest
Der Marker `@pytest.mark.anyio` teilt pytest mit, dass diese Testfunktion asynchron aufgerufen werden soll:
```Python hl_lines="7"
{!../../../docs_src/async_tests/test_main.py!}
{!../../docs_src/async_tests/test_main.py!}
```
/// tip | "Tipp"
@@ -72,8 +72,8 @@ Beachten Sie, dass die Testfunktion jetzt `async def` ist und nicht nur `def` wi
Dann können wir einen `AsyncClient` mit der App erstellen und mit `await` asynchrone Requests an ihn senden.
```Python hl_lines="9-10"
{!../../../docs_src/async_tests/test_main.py!}
```Python hl_lines="9-12"
{!../../docs_src/async_tests/test_main.py!}
```
Das ist das Äquivalent zu:

View File

@@ -19,7 +19,7 @@ In diesem Fall würde der ursprüngliche Pfad `/app` tatsächlich unter `/api/v1
Auch wenn Ihr gesamter Code unter der Annahme geschrieben ist, dass es nur `/app` gibt.
```Python hl_lines="6"
{!../../../docs_src/behind_a_proxy/tutorial001.py!}
{!../../docs_src/behind_a_proxy/tutorial001.py!}
```
Und der Proxy würde das **Pfadpräfix** on-the-fly **"entfernen**", bevor er die Anfrage an Uvicorn übermittelt, dafür sorgend, dass Ihre Anwendung davon überzeugt ist, dass sie unter `/app` bereitgestellt wird, sodass Sie nicht Ihren gesamten Code dahingehend aktualisieren müssen, das Präfix `/api/v1` zu verwenden.
@@ -99,7 +99,7 @@ Sie können den aktuellen `root_path` abrufen, der von Ihrer Anwendung für jede
Hier fügen wir ihn, nur zu Demonstrationszwecken, in die Nachricht ein.
```Python hl_lines="8"
{!../../../docs_src/behind_a_proxy/tutorial001.py!}
{!../../docs_src/behind_a_proxy/tutorial001.py!}
```
Wenn Sie Uvicorn dann starten mit:
@@ -128,7 +128,7 @@ wäre die Response etwa:
Falls Sie keine Möglichkeit haben, eine Kommandozeilenoption wie `--root-path` oder ähnlich zu übergeben, können Sie als Alternative beim Erstellen Ihrer FastAPI-Anwendung den Parameter `root_path` setzen:
```Python hl_lines="3"
{!../../../docs_src/behind_a_proxy/tutorial002.py!}
{!../../docs_src/behind_a_proxy/tutorial002.py!}
```
Die Übergabe des `root_path` an `FastAPI` wäre das Äquivalent zur Übergabe der `--root-path`-Kommandozeilenoption an Uvicorn oder Hypercorn.
@@ -310,7 +310,7 @@ Wenn Sie eine benutzerdefinierte Liste von Servern (`servers`) übergeben und es
Zum Beispiel:
```Python hl_lines="4-7"
{!../../../docs_src/behind_a_proxy/tutorial003.py!}
{!../../docs_src/behind_a_proxy/tutorial003.py!}
```
Erzeugt ein OpenAPI-Schema, wie:
@@ -359,7 +359,7 @@ Die Dokumentationsoberfläche interagiert mit dem von Ihnen ausgewählten Server
Wenn Sie nicht möchten, dass **FastAPI** einen automatischen Server inkludiert, welcher `root_path` verwendet, können Sie den Parameter `root_path_in_servers=False` verwenden:
```Python hl_lines="9"
{!../../../docs_src/behind_a_proxy/tutorial004.py!}
{!../../docs_src/behind_a_proxy/tutorial004.py!}
```
Dann wird er nicht in das OpenAPI-Schema aufgenommen.

View File

@@ -31,7 +31,7 @@ Das liegt daran, dass FastAPI standardmäßig jedes enthaltene Element überprü
Wenn Sie jedoch sicher sind, dass der von Ihnen zurückgegebene Inhalt **mit JSON serialisierbar** ist, können Sie ihn direkt an die Response-Klasse übergeben und die zusätzliche Arbeit vermeiden, die FastAPI hätte, indem es Ihren zurückgegebenen Inhalt durch den `jsonable_encoder` leitet, bevor es ihn an die Response-Klasse übergibt.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001b.py!}
{!../../docs_src/custom_response/tutorial001b.py!}
```
/// info
@@ -58,7 +58,7 @@ Um eine Response mit HTML direkt von **FastAPI** zurückzugeben, verwenden Sie `
* Übergeben Sie `HTMLResponse` als den Parameter `response_class` Ihres *Pfadoperation-Dekorators*.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial002.py!}
{!../../docs_src/custom_response/tutorial002.py!}
```
/// info
@@ -78,7 +78,7 @@ Wie in [Eine Response direkt zurückgeben](response-directly.md){.internal-link
Das gleiche Beispiel von oben, das eine `HTMLResponse` zurückgibt, könnte so aussehen:
```Python hl_lines="2 7 19"
{!../../../docs_src/custom_response/tutorial003.py!}
{!../../docs_src/custom_response/tutorial003.py!}
```
/// warning | "Achtung"
@@ -104,7 +104,7 @@ Die `response_class` wird dann nur zur Dokumentation der OpenAPI-Pfadoperation*
Es könnte zum Beispiel so etwas sein:
```Python hl_lines="7 21 23"
{!../../../docs_src/custom_response/tutorial004.py!}
{!../../docs_src/custom_response/tutorial004.py!}
```
In diesem Beispiel generiert die Funktion `generate_html_response()` bereits eine `Response` und gibt sie zurück, anstatt das HTML in einem `str` zurückzugeben.
@@ -145,7 +145,7 @@ Sie akzeptiert die folgenden Parameter:
FastAPI (eigentlich Starlette) fügt automatisch einen Content-Length-Header ein. Außerdem wird es einen Content-Type-Header einfügen, der auf dem media_type basiert, und für Texttypen einen Zeichensatz (charset) anfügen.
```Python hl_lines="1 18"
{!../../../docs_src/response_directly/tutorial002.py!}
{!../../docs_src/response_directly/tutorial002.py!}
```
### `HTMLResponse`
@@ -157,7 +157,7 @@ Nimmt Text oder Bytes entgegen und gibt eine HTML-Response zurück, wie Sie oben
Nimmt Text oder Bytes entgegen und gibt eine Plain-Text-Response zurück.
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial005.py!}
{!../../docs_src/custom_response/tutorial005.py!}
```
### `JSONResponse`
@@ -181,7 +181,7 @@ Eine alternative JSON-Response mit <a href="https://github.com/ultrajson/ultrajs
///
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001.py!}
{!../../docs_src/custom_response/tutorial001.py!}
```
/// tip | "Tipp"
@@ -197,7 +197,7 @@ Gibt eine HTTP-Weiterleitung (HTTP-Redirect) zurück. Verwendet standardmäßig
Sie können eine `RedirectResponse` direkt zurückgeben:
```Python hl_lines="2 9"
{!../../../docs_src/custom_response/tutorial006.py!}
{!../../docs_src/custom_response/tutorial006.py!}
```
---
@@ -206,7 +206,7 @@ Oder Sie können sie im Parameter `response_class` verwenden:
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial006b.py!}
{!../../docs_src/custom_response/tutorial006b.py!}
```
Wenn Sie das tun, können Sie die URL direkt von Ihrer *Pfadoperation*-Funktion zurückgeben.
@@ -218,7 +218,7 @@ In diesem Fall ist der verwendete `status_code` der Standardcode für die `Redir
Sie können den Parameter `status_code` auch in Kombination mit dem Parameter `response_class` verwenden:
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial006c.py!}
{!../../docs_src/custom_response/tutorial006c.py!}
```
### `StreamingResponse`
@@ -226,7 +226,7 @@ Sie können den Parameter `status_code` auch in Kombination mit dem Parameter `r
Nimmt einen asynchronen Generator oder einen normalen Generator/Iterator und streamt den Responsebody.
```Python hl_lines="2 14"
{!../../../docs_src/custom_response/tutorial007.py!}
{!../../docs_src/custom_response/tutorial007.py!}
```
#### Verwendung von `StreamingResponse` mit dateiähnlichen Objekten
@@ -238,7 +238,7 @@ Auf diese Weise müssen Sie nicht alles zuerst in den Arbeitsspeicher lesen und
Das umfasst viele Bibliotheken zur Interaktion mit Cloud-Speicher, Videoverarbeitung und anderen.
```{ .python .annotate hl_lines="2 10-12 14" }
{!../../../docs_src/custom_response/tutorial008.py!}
{!../../docs_src/custom_response/tutorial008.py!}
```
1. Das ist die Generatorfunktion. Es handelt sich um eine „Generatorfunktion“, da sie `yield`-Anweisungen enthält.
@@ -269,13 +269,13 @@ Nimmt zur Instanziierung einen anderen Satz von Argumenten entgegen als die ande
Datei-Responses enthalten die entsprechenden `Content-Length`-, `Last-Modified`- und `ETag`-Header.
```Python hl_lines="2 10"
{!../../../docs_src/custom_response/tutorial009.py!}
{!../../docs_src/custom_response/tutorial009.py!}
```
Sie können auch den Parameter `response_class` verwenden:
```Python hl_lines="2 8 10"
{!../../../docs_src/custom_response/tutorial009b.py!}
{!../../docs_src/custom_response/tutorial009b.py!}
```
In diesem Fall können Sie den Dateipfad direkt von Ihrer *Pfadoperation*-Funktion zurückgeben.
@@ -291,7 +291,7 @@ Sie möchten etwa, dass Ihre Response eingerücktes und formatiertes JSON zurüc
Sie könnten eine `CustomORJSONResponse` erstellen. Das Wichtigste, was Sie tun müssen, ist, eine `Response.render(content)`-Methode zu erstellen, die den Inhalt als `bytes` zurückgibt:
```Python hl_lines="9-14 17"
{!../../../docs_src/custom_response/tutorial009c.py!}
{!../../docs_src/custom_response/tutorial009c.py!}
```
Statt:
@@ -319,7 +319,7 @@ Der Parameter, der das definiert, ist `default_response_class`.
Im folgenden Beispiel verwendet **FastAPI** standardmäßig `ORJSONResponse` in allen *Pfadoperationen*, anstelle von `JSONResponse`.
```Python hl_lines="2 4"
{!../../../docs_src/custom_response/tutorial010.py!}
{!../../docs_src/custom_response/tutorial010.py!}
```
/// tip | "Tipp"

View File

@@ -5,7 +5,7 @@ FastAPI basiert auf **Pydantic** und ich habe Ihnen gezeigt, wie Sie Pydantic-Mo
Aber FastAPI unterstützt auf die gleiche Weise auch die Verwendung von <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!}
{!../../docs_src/dataclasses/tutorial001.py!}
```
Das ist dank **Pydantic** ebenfalls möglich, da es <a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">`dataclasses` intern unterstützt</a>.
@@ -35,7 +35,7 @@ Wenn Sie jedoch eine Menge Datenklassen herumliegen haben, ist dies ein guter Tr
Sie können `dataclasses` auch im Parameter `response_model` verwenden:
```Python hl_lines="1 7-13 19"
{!../../../docs_src/dataclasses/tutorial002.py!}
{!../../docs_src/dataclasses/tutorial002.py!}
```
Die Datenklasse wird automatisch in eine Pydantic-Datenklasse konvertiert.
@@ -53,7 +53,7 @@ In einigen Fällen müssen Sie möglicherweise immer noch Pydantics Version von
In diesem Fall können Sie einfach die Standard-`dataclasses` durch `pydantic.dataclasses` ersetzen, was einen direkten Ersatz darstellt:
```{ .python .annotate hl_lines="1 5 8-11 14-17 23-25 28" }
{!../../../docs_src/dataclasses/tutorial003.py!}
{!../../docs_src/dataclasses/tutorial003.py!}
```
1. Wir importieren `field` weiterhin von Standard-`dataclasses`.

View File

@@ -31,7 +31,7 @@ Beginnen wir mit einem Beispiel und sehen es uns dann im Detail an.
Wir erstellen eine asynchrone Funktion `lifespan()` mit `yield` wie folgt:
```Python hl_lines="16 19"
{!../../../docs_src/events/tutorial003.py!}
{!../../docs_src/events/tutorial003.py!}
```
Hier simulieren wir das langsame *Hochfahren*, das Laden des Modells, indem wir die (Fake-)Modellfunktion vor dem `yield` in das Dictionary mit Modellen für maschinelles Lernen einfügen. Dieser Code wird ausgeführt, **bevor** die Anwendung **beginnt, Requests entgegenzunehmen**, während des *Hochfahrens*.
@@ -51,7 +51,7 @@ Möglicherweise müssen Sie eine neue Version starten, oder Sie haben es einfach
Das Erste, was auffällt, ist, dass wir eine asynchrone Funktion mit `yield` definieren. Das ist sehr ähnlich zu Abhängigkeiten mit `yield`.
```Python hl_lines="14-19"
{!../../../docs_src/events/tutorial003.py!}
{!../../docs_src/events/tutorial003.py!}
```
Der erste Teil der Funktion, vor dem `yield`, wird ausgeführt **bevor** die Anwendung startet.
@@ -65,7 +65,7 @@ Wie Sie sehen, ist die Funktion mit einem `@asynccontextmanager` versehen.
Dadurch wird die Funktion in einen sogenannten „**asynchronen Kontextmanager**“ umgewandelt.
```Python hl_lines="1 13"
{!../../../docs_src/events/tutorial003.py!}
{!../../docs_src/events/tutorial003.py!}
```
Ein **Kontextmanager** in Python ist etwas, das Sie in einer `with`-Anweisung verwenden können, zum Beispiel kann `open()` als Kontextmanager verwendet werden:
@@ -89,7 +89,7 @@ In unserem obigen Codebeispiel verwenden wir ihn nicht direkt, sondern übergebe
Der Parameter `lifespan` der `FastAPI`-App benötigt einen **asynchronen Kontextmanager**, wir können ihm also unseren neuen asynchronen Kontextmanager `lifespan` übergeben.
```Python hl_lines="22"
{!../../../docs_src/events/tutorial003.py!}
{!../../docs_src/events/tutorial003.py!}
```
## Alternative Events (deprecated)
@@ -113,7 +113,7 @@ Diese Funktionen können mit `async def` oder normalem `def` deklariert werden.
Um eine Funktion hinzuzufügen, die vor dem Start der Anwendung ausgeführt werden soll, deklarieren Sie diese mit dem Event `startup`:
```Python hl_lines="8"
{!../../../docs_src/events/tutorial001.py!}
{!../../docs_src/events/tutorial001.py!}
```
In diesem Fall initialisiert die Eventhandler-Funktion `startup` die „Datenbank“ der Items (nur ein `dict`) mit einigen Werten.
@@ -127,7 +127,7 @@ Und Ihre Anwendung empfängt erst dann Anfragen, wenn alle `startup`-Eventhandle
Um eine Funktion hinzuzufügen, die beim Herunterfahren der Anwendung ausgeführt werden soll, deklarieren Sie sie mit dem Event `shutdown`:
```Python hl_lines="6"
{!../../../docs_src/events/tutorial002.py!}
{!../../docs_src/events/tutorial002.py!}
```
Hier schreibt die `shutdown`-Eventhandler-Funktion eine Textzeile `"Application shutdown"` in eine Datei `log.txt`.

View File

@@ -31,7 +31,7 @@ Beginnen wir mit einer einfachen FastAPI-Anwendung:
//// tab | Python 3.9+
```Python hl_lines="7-9 12-13 16-17 21"
{!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
{!> ../../docs_src/generate_clients/tutorial001_py39.py!}
```
////
@@ -39,7 +39,7 @@ Beginnen wir mit einer einfachen FastAPI-Anwendung:
//// tab | Python 3.8+
```Python hl_lines="9-11 14-15 18 19 23"
{!> ../../../docs_src/generate_clients/tutorial001.py!}
{!> ../../docs_src/generate_clients/tutorial001.py!}
```
////
@@ -150,7 +150,7 @@ Beispielsweise könnten Sie einen Abschnitt für **Items (Artikel)** und einen w
//// tab | Python 3.9+
```Python hl_lines="21 26 34"
{!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
{!> ../../docs_src/generate_clients/tutorial002_py39.py!}
```
////
@@ -158,7 +158,7 @@ Beispielsweise könnten Sie einen Abschnitt für **Items (Artikel)** und einen w
//// tab | Python 3.8+
```Python hl_lines="23 28 36"
{!> ../../../docs_src/generate_clients/tutorial002.py!}
{!> ../../docs_src/generate_clients/tutorial002.py!}
```
////
@@ -211,7 +211,7 @@ Anschließend können Sie diese benutzerdefinierte Funktion als Parameter `gener
//// tab | Python 3.9+
```Python hl_lines="6-7 10"
{!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
{!> ../../docs_src/generate_clients/tutorial003_py39.py!}
```
////
@@ -219,7 +219,7 @@ Anschließend können Sie diese benutzerdefinierte Funktion als Parameter `gener
//// tab | Python 3.8+
```Python hl_lines="8-9 12"
{!> ../../../docs_src/generate_clients/tutorial003.py!}
{!> ../../docs_src/generate_clients/tutorial003.py!}
```
////
@@ -247,7 +247,7 @@ Wir könnten das OpenAPI-JSON in eine Datei `openapi.json` herunterladen und dan
//// tab | Python
```Python
{!> ../../../docs_src/generate_clients/tutorial004.py!}
{!> ../../docs_src/generate_clients/tutorial004.py!}
```
////
@@ -255,7 +255,7 @@ Wir könnten das OpenAPI-JSON in eine Datei `openapi.json` herunterladen und dan
//// tab | Node.js
```Javascript
{!> ../../../docs_src/generate_clients/tutorial004.js!}
{!> ../../docs_src/generate_clients/tutorial004.js!}
```
////

View File

@@ -58,7 +58,7 @@ Erzwingt, dass alle eingehenden Requests entweder `https` oder `wss` sein müsse
Alle eingehenden Requests an `http` oder `ws` werden stattdessen an das sichere Schema umgeleitet.
```Python hl_lines="2 6"
{!../../../docs_src/advanced_middleware/tutorial001.py!}
{!../../docs_src/advanced_middleware/tutorial001.py!}
```
## `TrustedHostMiddleware`
@@ -66,7 +66,7 @@ Alle eingehenden Requests an `http` oder `ws` werden stattdessen an das sichere
Erzwingt, dass alle eingehenden Requests einen korrekt gesetzten `Host`-Header haben, um sich vor HTTP-Host-Header-Angriffen zu schützen.
```Python hl_lines="2 6-8"
{!../../../docs_src/advanced_middleware/tutorial002.py!}
{!../../docs_src/advanced_middleware/tutorial002.py!}
```
Die folgenden Argumente werden unterstützt:
@@ -82,7 +82,7 @@ Verarbeitet GZip-Responses für alle Requests, die `"gzip"` im `Accept-Encoding`
Diese Middleware verarbeitet sowohl Standard- als auch Streaming-Responses.
```Python hl_lines="2 6"
{!../../../docs_src/advanced_middleware/tutorial003.py!}
{!../../docs_src/advanced_middleware/tutorial003.py!}
```
Die folgenden Argumente werden unterstützt:
@@ -95,7 +95,6 @@ Es gibt viele andere ASGI-Middlewares.
Zum Beispiel:
* <a href="https://docs.sentry.io/platforms/python/guides/fastapi/" class="external-link" target="_blank">Sentry</a>
* <a href="https://github.com/encode/uvicorn/blob/master/uvicorn/middleware/proxy_headers.py" class="external-link" target="_blank">Uvicorns `ProxyHeadersMiddleware`</a>
* <a href="https://github.com/florimondmanca/msgpack-asgi" class="external-link" target="_blank">MessagePack</a>

View File

@@ -32,7 +32,7 @@ Sie verfügt über eine *Pfadoperation*, die einen `Invoice`-Body empfängt, und
Dieser Teil ist ziemlich normal, der größte Teil des Codes ist Ihnen wahrscheinlich bereits bekannt:
```Python hl_lines="9-13 36-53"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
{!../../docs_src/openapi_callbacks/tutorial001.py!}
```
/// tip | "Tipp"
@@ -93,7 +93,7 @@ Wenn Sie diese Sichtweise (des *externen Entwicklers*) vorübergehend übernehme
Erstellen Sie zunächst einen neuen `APIRouter`, der einen oder mehrere Callbacks enthält.
```Python hl_lines="3 25"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
{!../../docs_src/openapi_callbacks/tutorial001.py!}
```
### Die Callback-*Pfadoperation* erstellen
@@ -106,7 +106,7 @@ Sie sollte wie eine normale FastAPI-*Pfadoperation* aussehen:
* Und sie könnte auch eine Deklaration der Response enthalten, die zurückgegeben werden soll, z. B. `response_model=InvoiceEventReceived`.
```Python hl_lines="16-18 21-22 28-32"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
{!../../docs_src/openapi_callbacks/tutorial001.py!}
```
Es gibt zwei Hauptunterschiede zu einer normalen *Pfadoperation*:
@@ -176,7 +176,7 @@ An diesem Punkt haben Sie die benötigte(n) *Callback-Pfadoperation(en)* (diejen
Verwenden Sie nun den Parameter `callbacks` im *Pfadoperation-Dekorator Ihrer API*, um das Attribut `.routes` (das ist eigentlich nur eine `list`e von Routen/*Pfadoperationen*) dieses Callback-Routers zu übergeben:
```Python hl_lines="35"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
{!../../docs_src/openapi_callbacks/tutorial001.py!}
```
/// tip | "Tipp"

View File

@@ -33,7 +33,7 @@ Webhooks sind in OpenAPI 3.1.0 und höher verfügbar und werden von FastAPI `0.9
Wenn Sie eine **FastAPI**-Anwendung erstellen, gibt es ein `webhooks`-Attribut, mit dem Sie *Webhooks* definieren können, genauso wie Sie *Pfadoperationen* definieren würden, zum Beispiel mit `@app.webhooks.post()`.
```Python hl_lines="9-13 36-53"
{!../../../docs_src/openapi_webhooks/tutorial001.py!}
{!../../docs_src/openapi_webhooks/tutorial001.py!}
```
Die von Ihnen definierten Webhooks landen im **OpenAPI**-Schema und der automatischen **Dokumentations-Oberfläche**.

View File

@@ -13,7 +13,7 @@ Mit dem Parameter `operation_id` können Sie die OpenAPI `operationId` festlegen
Sie müssten sicherstellen, dass sie für jede Operation eindeutig ist.
```Python hl_lines="6"
{!../../../docs_src/path_operation_advanced_configuration/tutorial001.py!}
{!../../docs_src/path_operation_advanced_configuration/tutorial001.py!}
```
### Verwendung des Namens der *Pfadoperation-Funktion* als operationId
@@ -23,7 +23,7 @@ Wenn Sie die Funktionsnamen Ihrer API als `operationId`s verwenden möchten, kö
Sie sollten dies tun, nachdem Sie alle Ihre *Pfadoperationen* hinzugefügt haben.
```Python hl_lines="2 12-21 24"
{!../../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
{!../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
```
/// tip | "Tipp"
@@ -45,7 +45,7 @@ Auch wenn diese sich in unterschiedlichen Modulen (Python-Dateien) befinden.
Um eine *Pfadoperation* aus dem generierten OpenAPI-Schema (und damit aus den automatischen Dokumentationssystemen) auszuschließen, verwenden Sie den Parameter `include_in_schema` und setzen Sie ihn auf `False`:
```Python hl_lines="6"
{!../../../docs_src/path_operation_advanced_configuration/tutorial003.py!}
{!../../docs_src/path_operation_advanced_configuration/tutorial003.py!}
```
## Fortgeschrittene Beschreibung mittels Docstring
@@ -57,7 +57,7 @@ Das Hinzufügen eines `\f` (ein maskiertes „Form Feed“-Zeichen) führt dazu,
Sie wird nicht in der Dokumentation angezeigt, aber andere Tools (z. B. Sphinx) können den Rest verwenden.
```Python hl_lines="19-29"
{!../../../docs_src/path_operation_advanced_configuration/tutorial004.py!}
{!../../docs_src/path_operation_advanced_configuration/tutorial004.py!}
```
## Zusätzliche Responses
@@ -101,7 +101,7 @@ Sie können das OpenAPI-Schema für eine *Pfadoperation* erweitern, indem Sie de
Dieses `openapi_extra` kann beispielsweise hilfreich sein, um <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions" class="external-link" target="_blank">OpenAPI-Erweiterungen</a> zu deklarieren:
```Python hl_lines="6"
{!../../../docs_src/path_operation_advanced_configuration/tutorial005.py!}
{!../../docs_src/path_operation_advanced_configuration/tutorial005.py!}
```
Wenn Sie die automatische API-Dokumentation öffnen, wird Ihre Erweiterung am Ende der spezifischen *Pfadoperation* angezeigt.
@@ -150,7 +150,7 @@ Sie könnten sich beispielsweise dafür entscheiden, den Request mit Ihrem eigen
Das könnte man mit `openapi_extra` machen:
```Python hl_lines="20-37 39-40"
{!../../../docs_src/path_operation_advanced_configuration/tutorial006.py!}
{!../../docs_src/path_operation_advanced_configuration/tutorial006.py!}
```
In diesem Beispiel haben wir kein Pydantic-Modell deklariert. Tatsächlich wird der Requestbody nicht einmal als JSON <abbr title="von einem einfachen Format, wie Bytes, in Python-Objekte konvertieren">geparst</abbr>, sondern direkt als `bytes` gelesen und die Funktion `magic_data_reader ()` wäre dafür verantwortlich, ihn in irgendeiner Weise zu parsen.
@@ -168,7 +168,7 @@ In der folgenden Anwendung verwenden wir beispielsweise weder die integrierte Fu
//// tab | Pydantic v2
```Python hl_lines="17-22 24"
{!> ../../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
```
////
@@ -176,7 +176,7 @@ In der folgenden Anwendung verwenden wir beispielsweise weder die integrierte Fu
//// tab | Pydantic v1
```Python hl_lines="17-22 24"
{!> ../../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
```
////
@@ -196,7 +196,7 @@ Und dann parsen wir in unserem Code diesen YAML-Inhalt direkt und verwenden dann
//// tab | Pydantic v2
```Python hl_lines="26-33"
{!> ../../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
```
////
@@ -204,7 +204,7 @@ Und dann parsen wir in unserem Code diesen YAML-Inhalt direkt und verwenden dann
//// tab | Pydantic v1
```Python hl_lines="26-33"
{!> ../../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
```
////

View File

@@ -21,7 +21,7 @@ Sie können einen Parameter vom Typ `Response` in Ihrer *Pfadoperation-Funktion*
Anschließend können Sie den `status_code` in diesem *vorübergehenden* Response-Objekt festlegen.
```Python hl_lines="1 9 12"
{!../../../docs_src/response_change_status_code/tutorial001.py!}
{!../../docs_src/response_change_status_code/tutorial001.py!}
```
Und dann können Sie wie gewohnt jedes benötigte Objekt zurückgeben (ein `dict`, ein Datenbankmodell usw.).

View File

@@ -7,7 +7,7 @@ Sie können einen Parameter vom Typ `Response` in Ihrer *Pfadoperation-Funktion*
Und dann können Sie Cookies in diesem *vorübergehenden* Response-Objekt setzen.
```Python hl_lines="1 8-9"
{!../../../docs_src/response_cookies/tutorial002.py!}
{!../../docs_src/response_cookies/tutorial002.py!}
```
Anschließend können Sie wie gewohnt jedes gewünschte Objekt zurückgeben (ein `dict`, ein Datenbankmodell, usw.).
@@ -27,7 +27,7 @@ Dazu können Sie eine Response erstellen, wie unter [Eine Response direkt zurüc
Setzen Sie dann Cookies darin und geben Sie sie dann zurück:
```Python hl_lines="10-12"
{!../../../docs_src/response_cookies/tutorial001.py!}
{!../../docs_src/response_cookies/tutorial001.py!}
```
/// tip | "Tipp"

View File

@@ -35,7 +35,7 @@ Sie können beispielsweise kein Pydantic-Modell in eine `JSONResponse` einfügen
In diesen Fällen können Sie den `jsonable_encoder` verwenden, um Ihre Daten zu konvertieren, bevor Sie sie an eine Response übergeben:
```Python hl_lines="6-7 21-22"
{!../../../docs_src/response_directly/tutorial001.py!}
{!../../docs_src/response_directly/tutorial001.py!}
```
/// note | "Technische Details"
@@ -57,7 +57,7 @@ Nehmen wir an, Sie möchten eine <a href="https://en.wikipedia.org/wiki/XML" cla
Sie könnten Ihren XML-Inhalt als String in eine `Response` einfügen und sie zurückgeben:
```Python hl_lines="1 18"
{!../../../docs_src/response_directly/tutorial002.py!}
{!../../docs_src/response_directly/tutorial002.py!}
```
## Anmerkungen

View File

@@ -7,7 +7,7 @@ Sie können einen Parameter vom Typ `Response` in Ihrer *Pfadoperation-Funktion*
Und dann können Sie Header in diesem *vorübergehenden* Response-Objekt festlegen.
```Python hl_lines="1 7-8"
{!../../../docs_src/response_headers/tutorial002.py!}
{!../../docs_src/response_headers/tutorial002.py!}
```
Anschließend können Sie wie gewohnt jedes gewünschte Objekt zurückgeben (ein `dict`, ein Datenbankmodell, usw.).
@@ -25,7 +25,7 @@ Sie können auch Header hinzufügen, wenn Sie eine `Response` direkt zurückgebe
Erstellen Sie eine Response wie in [Eine Response direkt zurückgeben](response-directly.md){.internal-link target=_blank} beschrieben und übergeben Sie die Header als zusätzlichen Parameter:
```Python hl_lines="10-12"
{!../../../docs_src/response_headers/tutorial001.py!}
{!../../docs_src/response_headers/tutorial001.py!}
```
/// note | "Technische Details"

View File

@@ -23,7 +23,7 @@ Wenn Sie dann den Benutzernamen und das Passwort eingeben, sendet der Browser di
//// tab | Python 3.9+
```Python hl_lines="4 8 12"
{!> ../../../docs_src/security/tutorial006_an_py39.py!}
{!> ../../docs_src/security/tutorial006_an_py39.py!}
```
////
@@ -31,7 +31,7 @@ Wenn Sie dann den Benutzernamen und das Passwort eingeben, sendet der Browser di
//// tab | Python 3.8+
```Python hl_lines="2 7 11"
{!> ../../../docs_src/security/tutorial006_an.py!}
{!> ../../docs_src/security/tutorial006_an.py!}
```
////
@@ -45,7 +45,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="2 6 10"
{!> ../../../docs_src/security/tutorial006.py!}
{!> ../../docs_src/security/tutorial006.py!}
```
////
@@ -71,7 +71,7 @@ Dann können wir `secrets.compare_digest()` verwenden, um sicherzustellen, dass
//// tab | Python 3.9+
```Python hl_lines="1 12-24"
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
{!> ../../docs_src/security/tutorial007_an_py39.py!}
```
////
@@ -79,7 +79,7 @@ Dann können wir `secrets.compare_digest()` verwenden, um sicherzustellen, dass
//// tab | Python 3.8+
```Python hl_lines="1 12-24"
{!> ../../../docs_src/security/tutorial007_an.py!}
{!> ../../docs_src/security/tutorial007_an.py!}
```
////
@@ -93,7 +93,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1 11-21"
{!> ../../../docs_src/security/tutorial007.py!}
{!> ../../docs_src/security/tutorial007.py!}
```
////
@@ -163,7 +163,7 @@ Nachdem Sie festgestellt haben, dass die Anmeldeinformationen falsch sind, geben
//// tab | Python 3.9+
```Python hl_lines="26-30"
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
{!> ../../docs_src/security/tutorial007_an_py39.py!}
```
////
@@ -171,7 +171,7 @@ Nachdem Sie festgestellt haben, dass die Anmeldeinformationen falsch sind, geben
//// tab | Python 3.8+
```Python hl_lines="26-30"
{!> ../../../docs_src/security/tutorial007_an.py!}
{!> ../../docs_src/security/tutorial007_an.py!}
```
////
@@ -185,7 +185,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="23-27"
{!> ../../../docs_src/security/tutorial007.py!}
{!> ../../docs_src/security/tutorial007.py!}
```
////

View File

@@ -65,7 +65,7 @@ Sehen wir uns zunächst kurz die Teile an, die sich gegenüber den Beispielen im
//// tab | Python 3.10+
```Python hl_lines="4 8 12 46 64 105 107-115 121-124 128-134 139 155"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -73,7 +73,7 @@ Sehen wir uns zunächst kurz die Teile an, die sich gegenüber den Beispielen im
//// tab | Python 3.9+
```Python hl_lines="2 4 8 12 46 64 105 107-115 121-124 128-134 139 155"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -81,7 +81,7 @@ Sehen wir uns zunächst kurz die Teile an, die sich gegenüber den Beispielen im
//// tab | Python 3.8+
```Python hl_lines="2 4 8 12 47 65 106 108-116 122-125 129-135 140 156"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -95,7 +95,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3 7 11 45 63 104 106-114 120-123 127-133 138 154"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -109,7 +109,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="2 4 8 12 46 64 105 107-115 121-124 128-134 139 155"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -123,7 +123,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="2 4 8 12 46 64 105 107-115 121-124 128-134 139 155"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -139,7 +139,7 @@ Der `scopes`-Parameter erhält ein `dict` mit jedem Scope als Schlüssel und des
//// tab | Python 3.10+
```Python hl_lines="62-65"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -147,7 +147,7 @@ Der `scopes`-Parameter erhält ein `dict` mit jedem Scope als Schlüssel und des
//// tab | Python 3.9+
```Python hl_lines="62-65"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -155,7 +155,7 @@ Der `scopes`-Parameter erhält ein `dict` mit jedem Scope als Schlüssel und des
//// tab | Python 3.8+
```Python hl_lines="63-66"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -169,7 +169,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="61-64"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -183,7 +183,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="62-65"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -197,7 +197,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="62-65"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -229,7 +229,7 @@ Aus Sicherheitsgründen sollten Sie jedoch sicherstellen, dass Sie in Ihrer Anwe
//// tab | Python 3.10+
```Python hl_lines="155"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -237,7 +237,7 @@ Aus Sicherheitsgründen sollten Sie jedoch sicherstellen, dass Sie in Ihrer Anwe
//// tab | Python 3.9+
```Python hl_lines="155"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -245,7 +245,7 @@ Aus Sicherheitsgründen sollten Sie jedoch sicherstellen, dass Sie in Ihrer Anwe
//// tab | Python 3.8+
```Python hl_lines="156"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -259,7 +259,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="154"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -273,7 +273,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="155"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -287,7 +287,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="155"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -319,7 +319,7 @@ Wir tun dies hier, um zu demonstrieren, wie **FastAPI** auf verschiedenen Ebenen
//// tab | Python 3.10+
```Python hl_lines="4 139 170"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -327,7 +327,7 @@ Wir tun dies hier, um zu demonstrieren, wie **FastAPI** auf verschiedenen Ebenen
//// tab | Python 3.9+
```Python hl_lines="4 139 170"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -335,7 +335,7 @@ Wir tun dies hier, um zu demonstrieren, wie **FastAPI** auf verschiedenen Ebenen
//// tab | Python 3.8+
```Python hl_lines="4 140 171"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -349,7 +349,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3 138 167"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -363,7 +363,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="4 139 168"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -377,7 +377,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="4 139 168"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -409,7 +409,7 @@ Diese `SecurityScopes`-Klasse ähnelt `Request` (`Request` wurde verwendet, um d
//// tab | Python 3.10+
```Python hl_lines="8 105"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -417,7 +417,7 @@ Diese `SecurityScopes`-Klasse ähnelt `Request` (`Request` wurde verwendet, um d
//// tab | Python 3.9+
```Python hl_lines="8 105"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -425,7 +425,7 @@ Diese `SecurityScopes`-Klasse ähnelt `Request` (`Request` wurde verwendet, um d
//// tab | Python 3.8+
```Python hl_lines="8 106"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -439,7 +439,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7 104"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -453,7 +453,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8 105"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -467,7 +467,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8 105"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -487,7 +487,7 @@ In diese Exception fügen wir (falls vorhanden) die erforderlichen Scopes als du
//// tab | Python 3.10+
```Python hl_lines="105 107-115"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -495,7 +495,7 @@ In diese Exception fügen wir (falls vorhanden) die erforderlichen Scopes als du
//// tab | Python 3.9+
```Python hl_lines="105 107-115"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -503,7 +503,7 @@ In diese Exception fügen wir (falls vorhanden) die erforderlichen Scopes als du
//// tab | Python 3.8+
```Python hl_lines="106 108-116"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -517,7 +517,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="104 106-114"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -531,7 +531,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="105 107-115"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -545,7 +545,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="105 107-115"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -567,7 +567,7 @@ Wir verifizieren auch, dass wir einen Benutzer mit diesem Benutzernamen haben, u
//// tab | Python 3.10+
```Python hl_lines="46 116-127"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -575,7 +575,7 @@ Wir verifizieren auch, dass wir einen Benutzer mit diesem Benutzernamen haben, u
//// tab | Python 3.9+
```Python hl_lines="46 116-127"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -583,7 +583,7 @@ Wir verifizieren auch, dass wir einen Benutzer mit diesem Benutzernamen haben, u
//// tab | Python 3.8+
```Python hl_lines="47 117-128"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -597,7 +597,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="45 115-126"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -611,7 +611,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="46 116-127"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -625,7 +625,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="46 116-127"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////
@@ -639,7 +639,7 @@ Hierzu verwenden wir `security_scopes.scopes`, das eine `list`e mit allen diesen
//// tab | Python 3.10+
```Python hl_lines="128-134"
{!> ../../../docs_src/security/tutorial005_an_py310.py!}
{!> ../../docs_src/security/tutorial005_an_py310.py!}
```
////
@@ -647,7 +647,7 @@ Hierzu verwenden wir `security_scopes.scopes`, das eine `list`e mit allen diesen
//// tab | Python 3.9+
```Python hl_lines="128-134"
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
{!> ../../docs_src/security/tutorial005_an_py39.py!}
```
////
@@ -655,7 +655,7 @@ Hierzu verwenden wir `security_scopes.scopes`, das eine `list`e mit allen diesen
//// tab | Python 3.8+
```Python hl_lines="129-135"
{!> ../../../docs_src/security/tutorial005_an.py!}
{!> ../../docs_src/security/tutorial005_an.py!}
```
////
@@ -669,7 +669,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="127-133"
{!> ../../../docs_src/security/tutorial005_py310.py!}
{!> ../../docs_src/security/tutorial005_py310.py!}
```
////
@@ -683,7 +683,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="128-134"
{!> ../../../docs_src/security/tutorial005_py39.py!}
{!> ../../docs_src/security/tutorial005_py39.py!}
```
////
@@ -697,7 +697,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="128-134"
{!> ../../../docs_src/security/tutorial005.py!}
{!> ../../docs_src/security/tutorial005.py!}
```
////

View File

@@ -181,7 +181,7 @@ Sie können dieselben Validierungs-Funktionen und -Tools verwenden, die Sie für
//// tab | Pydantic v2
```Python hl_lines="2 5-8 11"
{!> ../../../docs_src/settings/tutorial001.py!}
{!> ../../docs_src/settings/tutorial001.py!}
```
////
@@ -195,7 +195,7 @@ In Pydantic v1 würden Sie `BaseSettings` direkt von `pydantic` statt von `pydan
///
```Python hl_lines="2 5-8 11"
{!> ../../../docs_src/settings/tutorial001_pv1.py!}
{!> ../../docs_src/settings/tutorial001_pv1.py!}
```
////
@@ -215,7 +215,7 @@ Als Nächstes werden die Daten konvertiert und validiert. Wenn Sie also dieses `
Dann können Sie das neue `settings`-Objekt in Ihrer Anwendung verwenden:
```Python hl_lines="18-20"
{!../../../docs_src/settings/tutorial001.py!}
{!../../docs_src/settings/tutorial001.py!}
```
### Den Server ausführen
@@ -251,13 +251,13 @@ Sie könnten diese Einstellungen in eine andere Moduldatei einfügen, wie Sie in
Sie könnten beispielsweise eine Datei `config.py` haben mit:
```Python
{!../../../docs_src/settings/app01/config.py!}
{!../../docs_src/settings/app01/config.py!}
```
Und dann verwenden Sie diese in einer Datei `main.py`:
```Python hl_lines="3 11-13"
{!../../../docs_src/settings/app01/main.py!}
{!../../docs_src/settings/app01/main.py!}
```
/// tip | "Tipp"
@@ -277,7 +277,7 @@ Dies könnte besonders beim Testen nützlich sein, da es sehr einfach ist, eine
Ausgehend vom vorherigen Beispiel könnte Ihre Datei `config.py` so aussehen:
```Python hl_lines="10"
{!../../../docs_src/settings/app02/config.py!}
{!../../docs_src/settings/app02/config.py!}
```
Beachten Sie, dass wir jetzt keine Standardinstanz `settings = Settings()` erstellen.
@@ -289,7 +289,7 @@ Jetzt erstellen wir eine Abhängigkeit, die ein neues `config.Settings()` zurüc
//// tab | Python 3.9+
```Python hl_lines="6 12-13"
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
{!> ../../docs_src/settings/app02_an_py39/main.py!}
```
////
@@ -297,7 +297,7 @@ Jetzt erstellen wir eine Abhängigkeit, die ein neues `config.Settings()` zurüc
//// tab | Python 3.8+
```Python hl_lines="6 12-13"
{!> ../../../docs_src/settings/app02_an/main.py!}
{!> ../../docs_src/settings/app02_an/main.py!}
```
////
@@ -311,7 +311,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="5 11-12"
{!> ../../../docs_src/settings/app02/main.py!}
{!> ../../docs_src/settings/app02/main.py!}
```
////
@@ -329,7 +329,7 @@ Und dann können wir das von der *Pfadoperation-Funktion* als Abhängigkeit einf
//// tab | Python 3.9+
```Python hl_lines="17 19-21"
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
{!> ../../docs_src/settings/app02_an_py39/main.py!}
```
////
@@ -337,7 +337,7 @@ Und dann können wir das von der *Pfadoperation-Funktion* als Abhängigkeit einf
//// tab | Python 3.8+
```Python hl_lines="17 19-21"
{!> ../../../docs_src/settings/app02_an/main.py!}
{!> ../../docs_src/settings/app02_an/main.py!}
```
////
@@ -351,7 +351,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="16 18-20"
{!> ../../../docs_src/settings/app02/main.py!}
{!> ../../docs_src/settings/app02/main.py!}
```
////
@@ -361,7 +361,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
Dann wäre es sehr einfach, beim Testen ein anderes Einstellungsobjekt bereitzustellen, indem man eine Abhängigkeitsüberschreibung für `get_settings` erstellt:
```Python hl_lines="9-10 13 21"
{!../../../docs_src/settings/app02/test_main.py!}
{!../../docs_src/settings/app02/test_main.py!}
```
Bei der Abhängigkeitsüberschreibung legen wir einen neuen Wert für `admin_email` fest, wenn wir das neue `Settings`-Objekt erstellen, und geben dann dieses neue Objekt zurück.
@@ -406,7 +406,7 @@ Und dann aktualisieren Sie Ihre `config.py` mit:
//// tab | Pydantic v2
```Python hl_lines="9"
{!> ../../../docs_src/settings/app03_an/config.py!}
{!> ../../docs_src/settings/app03_an/config.py!}
```
/// tip | "Tipp"
@@ -420,7 +420,7 @@ Das Attribut `model_config` wird nur für die Pydantic-Konfiguration verwendet.
//// tab | Pydantic v1
```Python hl_lines="9-10"
{!> ../../../docs_src/settings/app03_an/config_pv1.py!}
{!> ../../docs_src/settings/app03_an/config_pv1.py!}
```
/// tip | "Tipp"
@@ -465,7 +465,7 @@ Da wir jedoch den `@lru_cache`-Dekorator oben verwenden, wird das `Settings`-Obj
//// tab | Python 3.9+
```Python hl_lines="1 11"
{!> ../../../docs_src/settings/app03_an_py39/main.py!}
{!> ../../docs_src/settings/app03_an_py39/main.py!}
```
////
@@ -473,7 +473,7 @@ Da wir jedoch den `@lru_cache`-Dekorator oben verwenden, wird das `Settings`-Obj
//// tab | Python 3.8+
```Python hl_lines="1 11"
{!> ../../../docs_src/settings/app03_an/main.py!}
{!> ../../docs_src/settings/app03_an/main.py!}
```
////
@@ -487,7 +487,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1 10"
{!> ../../../docs_src/settings/app03/main.py!}
{!> ../../docs_src/settings/app03/main.py!}
```
////

View File

@@ -11,7 +11,7 @@ Wenn Sie zwei unabhängige FastAPI-Anwendungen mit deren eigenen unabhängigen O
Erstellen Sie zunächst die Hauptanwendung **FastAPI** und deren *Pfadoperationen*:
```Python hl_lines="3 6-8"
{!../../../docs_src/sub_applications/tutorial001.py!}
{!../../docs_src/sub_applications/tutorial001.py!}
```
### Unteranwendung
@@ -21,7 +21,7 @@ Erstellen Sie dann Ihre Unteranwendung und deren *Pfadoperationen*.
Diese Unteranwendung ist nur eine weitere Standard-FastAPI-Anwendung, aber diese wird „gemountet“:
```Python hl_lines="11 14-16"
{!../../../docs_src/sub_applications/tutorial001.py!}
{!../../docs_src/sub_applications/tutorial001.py!}
```
### Die Unteranwendung mounten
@@ -31,7 +31,7 @@ Mounten Sie in Ihrer Top-Level-Anwendung `app` die Unteranwendung `subapi`.
In diesem Fall wird sie im Pfad `/subapi` gemountet:
```Python hl_lines="11 19"
{!../../../docs_src/sub_applications/tutorial001.py!}
{!../../docs_src/sub_applications/tutorial001.py!}
```
### Es in der automatischen API-Dokumentation betrachten

View File

@@ -28,7 +28,7 @@ $ pip install jinja2
* Verwenden Sie die von Ihnen erstellten `templates`, um eine `TemplateResponse` zu rendern und zurückzugeben, übergeben Sie den Namen des Templates, das Requestobjekt und ein „Kontext“-Dictionary mit Schlüssel-Wert-Paaren, die innerhalb des Jinja2-Templates verwendet werden sollen.
```Python hl_lines="4 11 15-18"
{!../../../docs_src/templates/tutorial001.py!}
{!../../docs_src/templates/tutorial001.py!}
```
/// note | "Hinweis"
@@ -58,7 +58,7 @@ Sie können auch `from starlette.templating import Jinja2Templates` verwenden.
Dann können Sie unter `templates/item.html` ein Template erstellen, mit z. B. folgendem Inhalt:
```jinja hl_lines="7"
{!../../../docs_src/templates/templates/item.html!}
{!../../docs_src/templates/templates/item.html!}
```
### Template-Kontextwerte
@@ -112,13 +112,13 @@ Mit beispielsweise der ID `42` würde dies Folgendes ergeben:
Sie können `url_for()` innerhalb des Templates auch beispielsweise mit den `StaticFiles` verwenden, die Sie mit `name="static"` gemountet haben.
```jinja hl_lines="4"
{!../../../docs_src/templates/templates/item.html!}
{!../../docs_src/templates/templates/item.html!}
```
In diesem Beispiel würde das zu einer CSS-Datei unter `static/styles.css` verlinken, mit folgendem Inhalt:
```CSS hl_lines="4"
{!../../../docs_src/templates/static/styles.css!}
{!../../docs_src/templates/static/styles.css!}
```
Und da Sie `StaticFiles` verwenden, wird diese CSS-Datei automatisch von Ihrer **FastAPI**-Anwendung unter der URL `/static/styles.css` bereitgestellt.

View File

@@ -31,7 +31,7 @@ Und dann ruft **FastAPI** diese Überschreibung anstelle der ursprünglichen Abh
//// tab | Python 3.10+
```Python hl_lines="26-27 30"
{!> ../../../docs_src/dependency_testing/tutorial001_an_py310.py!}
{!> ../../docs_src/dependency_testing/tutorial001_an_py310.py!}
```
////
@@ -39,7 +39,7 @@ Und dann ruft **FastAPI** diese Überschreibung anstelle der ursprünglichen Abh
//// tab | Python 3.9+
```Python hl_lines="28-29 32"
{!> ../../../docs_src/dependency_testing/tutorial001_an_py39.py!}
{!> ../../docs_src/dependency_testing/tutorial001_an_py39.py!}
```
////
@@ -47,7 +47,7 @@ Und dann ruft **FastAPI** diese Überschreibung anstelle der ursprünglichen Abh
//// tab | Python 3.8+
```Python hl_lines="29-30 33"
{!> ../../../docs_src/dependency_testing/tutorial001_an.py!}
{!> ../../docs_src/dependency_testing/tutorial001_an.py!}
```
////
@@ -61,7 +61,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="24-25 28"
{!> ../../../docs_src/dependency_testing/tutorial001_py310.py!}
{!> ../../docs_src/dependency_testing/tutorial001_py310.py!}
```
////
@@ -75,7 +75,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="28-29 32"
{!> ../../../docs_src/dependency_testing/tutorial001.py!}
{!> ../../docs_src/dependency_testing/tutorial001.py!}
```
////

View File

@@ -3,5 +3,5 @@
Wenn Sie in Ihren Tests Ihre Event-Handler (`startup` und `shutdown`) ausführen wollen, können Sie den `TestClient` mit einer `with`-Anweisung verwenden:
```Python hl_lines="9-12 20-24"
{!../../../docs_src/app_testing/tutorial003.py!}
{!../../docs_src/app_testing/tutorial003.py!}
```

View File

@@ -5,7 +5,7 @@ Sie können den schon bekannten `TestClient` zum Testen von WebSockets verwenden
Dazu verwenden Sie den `TestClient` in einer `with`-Anweisung, eine Verbindung zum WebSocket herstellend:
```Python hl_lines="27-31"
{!../../../docs_src/app_testing/tutorial002.py!}
{!../../docs_src/app_testing/tutorial002.py!}
```
/// note | "Hinweis"

View File

@@ -30,7 +30,7 @@ Angenommen, Sie möchten auf die IP-Adresse/den Host des Clients in Ihrer *Pfado
Dazu müssen Sie direkt auf den Request zugreifen.
```Python hl_lines="1 7-8"
{!../../../docs_src/using_request_directly/tutorial001.py!}
{!../../docs_src/using_request_directly/tutorial001.py!}
```
Durch die Deklaration eines *Pfadoperation-Funktionsparameters*, dessen Typ der `Request` ist, weiß **FastAPI**, dass es den `Request` diesem Parameter übergeben soll.

View File

@@ -39,7 +39,7 @@ In der Produktion hätten Sie eine der oben genannten Optionen.
Aber es ist die einfachste Möglichkeit, sich auf die Serverseite von WebSockets zu konzentrieren und ein funktionierendes Beispiel zu haben:
```Python hl_lines="2 6-38 41-43"
{!../../../docs_src/websockets/tutorial001.py!}
{!../../docs_src/websockets/tutorial001.py!}
```
## Einen `websocket` erstellen
@@ -47,7 +47,7 @@ Aber es ist die einfachste Möglichkeit, sich auf die Serverseite von WebSockets
Erstellen Sie in Ihrer **FastAPI**-Anwendung einen `websocket`:
```Python hl_lines="1 46-47"
{!../../../docs_src/websockets/tutorial001.py!}
{!../../docs_src/websockets/tutorial001.py!}
```
/// note | "Technische Details"
@@ -63,7 +63,7 @@ Sie können auch `from starlette.websockets import WebSocket` verwenden.
In Ihrer WebSocket-Route können Sie Nachrichten `await`en und Nachrichten senden.
```Python hl_lines="48-52"
{!../../../docs_src/websockets/tutorial001.py!}
{!../../docs_src/websockets/tutorial001.py!}
```
Sie können Binär-, Text- und JSON-Daten empfangen und senden.
@@ -118,7 +118,7 @@ Diese funktionieren auf die gleiche Weise wie für andere FastAPI-Endpunkte/*Pfa
//// tab | Python 3.10+
```Python hl_lines="68-69 82"
{!> ../../../docs_src/websockets/tutorial002_an_py310.py!}
{!> ../../docs_src/websockets/tutorial002_an_py310.py!}
```
////
@@ -126,7 +126,7 @@ Diese funktionieren auf die gleiche Weise wie für andere FastAPI-Endpunkte/*Pfa
//// tab | Python 3.9+
```Python hl_lines="68-69 82"
{!> ../../../docs_src/websockets/tutorial002_an_py39.py!}
{!> ../../docs_src/websockets/tutorial002_an_py39.py!}
```
////
@@ -134,7 +134,7 @@ Diese funktionieren auf die gleiche Weise wie für andere FastAPI-Endpunkte/*Pfa
//// tab | Python 3.8+
```Python hl_lines="69-70 83"
{!> ../../../docs_src/websockets/tutorial002_an.py!}
{!> ../../docs_src/websockets/tutorial002_an.py!}
```
////
@@ -148,7 +148,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="66-67 79"
{!> ../../../docs_src/websockets/tutorial002_py310.py!}
{!> ../../docs_src/websockets/tutorial002_py310.py!}
```
////
@@ -162,7 +162,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="68-69 81"
{!> ../../../docs_src/websockets/tutorial002.py!}
{!> ../../docs_src/websockets/tutorial002.py!}
```
////
@@ -213,7 +213,7 @@ Wenn eine WebSocket-Verbindung geschlossen wird, löst `await websocket.receive_
//// tab | Python 3.9+
```Python hl_lines="79-81"
{!> ../../../docs_src/websockets/tutorial003_py39.py!}
{!> ../../docs_src/websockets/tutorial003_py39.py!}
```
////
@@ -221,7 +221,7 @@ Wenn eine WebSocket-Verbindung geschlossen wird, löst `await websocket.receive_
//// tab | Python 3.8+
```Python hl_lines="81-83"
{!> ../../../docs_src/websockets/tutorial003.py!}
{!> ../../docs_src/websockets/tutorial003.py!}
```
////

View File

@@ -13,7 +13,7 @@ Wrappen Sie dann die WSGI-Anwendung (z. B. Flask) mit der Middleware.
Und dann mounten Sie das auf einem Pfad.
```Python hl_lines="2-3 23"
{!../../../docs_src/wsgi/tutorial001.py!}
{!../../docs_src/wsgi/tutorial001.py!}
```
## Es ansehen

View File

@@ -1,176 +0,0 @@
---
hide:
- navigation
---
# FastAPI Leute
FastAPI hat eine großartige Gemeinschaft, die Menschen mit unterschiedlichstem Hintergrund willkommen heißt.
## Erfinder - Betreuer
Hey! 👋
Das bin ich:
{% 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">Answers: {{ user.answers }}</div><div class="count">Pull Requests: {{ user.prs }}</div></div>
{% endfor %}
</div>
{% endif %}
Ich bin der Erfinder und Betreuer von **FastAPI**. Sie können mehr darüber in [FastAPI helfen Hilfe erhalten Mit dem Autor vernetzen](help-fastapi.md#mit-dem-autor-vernetzen){.internal-link target=_blank} erfahren.
... Aber hier möchte ich Ihnen die Gemeinschaft vorstellen.
---
**FastAPI** erhält eine Menge Unterstützung aus der Gemeinschaft. Und ich möchte ihre Beiträge hervorheben.
Das sind die Menschen, die:
* [Anderen bei Fragen auf GitHub helfen](help-fastapi.md#anderen-bei-fragen-auf-github-helfen){.internal-link target=_blank}.
* [<abbr title='Pull Request „Zieh-Anfrage“: Geänderten Quellcode senden, mit dem Vorschlag, ihn mit dem aktuellen Quellcode zu verschmelzen'>Pull Requests</abbr> erstellen](help-fastapi.md#einen-pull-request-erstellen){.internal-link target=_blank}.
* Pull Requests überprüfen (Review), [besonders wichtig für Übersetzungen](contributing.md#ubersetzungen){.internal-link target=_blank}.
Eine Runde Applaus für sie. 👏 🙇
## Aktivste Benutzer im letzten Monat
Hier die Benutzer, die im letzten Monat am meisten [anderen mit Fragen auf Github](help-fastapi.md#anderen-bei-fragen-auf-github-helfen){.internal-link target=_blank} geholfen haben. ☕
{% 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">Fragen beantwortet: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## Experten
Hier die **FastAPI-Experten**. 🤓
Das sind die Benutzer, die *insgesamt* [anderen am meisten mit Fragen auf GitHub geholfen haben](help-fastapi.md#anderen-bei-fragen-auf-github-helfen){.internal-link target=_blank}.
Sie haben bewiesen, dass sie Experten sind, weil sie vielen anderen geholfen haben. ✨
{% 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">Fragen beantwortet: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## Top-Mitwirkende
Hier sind die **Top-Mitwirkenden**. 👷
Diese Benutzer haben [die meisten Pull Requests erstellt](help-fastapi.md#einen-pull-request-erstellen){.internal-link target=_blank} welche *<abbr title="Mergen Zusammenführen: Unterschiedliche Versionen eines Quellcodes zusammenführen">gemerged</abbr>* wurden.
Sie haben Quellcode, Dokumentation, Übersetzungen, usw. beigesteuert. 📦
{% 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">Pull Requests: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
Es gibt viele andere Mitwirkende (mehr als hundert), Sie können sie alle auf der <a href="https://github.com/fastapi/fastapi/graphs/contributors" class="external-link" target="_blank">FastAPI GitHub Contributors-Seite</a> sehen. 👷
## Top-Rezensenten
Diese Benutzer sind die **Top-Rezensenten**. 🕵️
### Rezensionen für Übersetzungen
Ich spreche nur ein paar Sprachen (und nicht sehr gut 😅). Daher bestätigen Reviewer [**Übersetzungen der Dokumentation**](contributing.md#ubersetzungen){.internal-link target=_blank}. Ohne sie gäbe es keine Dokumentation in mehreren anderen Sprachen.
---
Die **Top-Reviewer** 🕵️ haben die meisten Pull Requests von anderen überprüft und stellen die Qualität des Codes, der Dokumentation und insbesondere der **Übersetzungen** sicher.
{% 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">Reviews: {{ user.count }}</div></div>
{% endfor %}
</div>
{% endif %}
## Sponsoren
Dies sind die **Sponsoren**. 😎
Sie unterstützen meine Arbeit an **FastAPI** (und andere), hauptsächlich durch <a href="https://github.com/sponsors/tiangolo" class="external-link" target="_blank">GitHub-Sponsoren</a>.
### Gold Sponsoren
{% if sponsors %}
{% for sponsor in sponsors.gold -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}"></a>
{% endfor %}
{% endif %}
### Silber Sponsoren
{% if sponsors %}
{% for sponsor in sponsors.silver -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}"></a>
{% endfor %}
{% endif %}
{% if people %}
{% if people.sponsors_50 %}
### Bronze Sponsoren
<div class="user-list user-list-center">
{% for user in people.sponsors_50 %}
<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>
{% endfor %}
</div>
{% endif %}
{% endif %}
### Individuelle Sponsoren
{% if people %}
<div class="user-list user-list-center">
{% for user in people.sponsors %}
<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>
{% endfor %}
</div>
{% endif %}
## Über diese Daten - technische Details
Der Hauptzweck dieser Seite ist es zu zeigen, wie die Gemeinschaft anderen hilft.
Das beinhaltet auch Hilfe, die normalerweise weniger sichtbar und in vielen Fällen mühsamer ist, wie, anderen bei Problemen zu helfen und Pull Requests mit Übersetzungen zu überprüfen.
Diese Daten werden jeden Monat berechnet, Sie können den <a href="https://github.com/fastapi/fastapi/blob/master/.github/actions/people/app/main.py" class="external-link" target="_blank">Quellcode hier lesen</a>.
Hier weise ich auch auf Beiträge von Sponsoren hin.
Ich behalte mir auch das Recht vor, den Algorithmus, die Abschnitte, die Schwellenwerte usw. zu aktualisieren (nur für den Fall 🤷).

View File

@@ -6,7 +6,7 @@
### Basiert auf offenen Standards
* <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> für die Erstellung von APIs, inklusive Deklarationen von <abbr title="auch genannt Endpunkte, Routen">Pfad</abbr>-<abbr title="gemeint sind HTTP-Methoden wie POST, GET, PUT, DELETE">Operationen</abbr>, Parametern, Body-Anfragen, Sicherheit, usw.
* <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank"><strong>OpenAPI</strong></a> für die Erstellung von APIs, inklusive Deklarationen von <abbr title="auch genannt Endpunkte, Routen">Pfad</abbr>-<abbr title="gemeint sind HTTP-Methoden wie POST, GET, PUT, DELETE">Operationen</abbr>, Parametern, Requestbodys, Sicherheit, usw.
* Automatische Dokumentation der Datenmodelle mit <a href="https://json-schema.org/" class="external-link" target="_blank"><strong>JSON Schema</strong></a> (da OpenAPI selbst auf JSON Schema basiert).
* Um diese Standards herum entworfen, nach sorgfältigem Studium. Statt einer nachträglichen Schicht darüber.
* Dies ermöglicht auch automatische **Client-Code-Generierung** in vielen Sprachen.

View File

@@ -30,7 +30,7 @@ Sie können problemlos dieselben Pydantic-Einstellungen verwenden, um Ihre gener
Zum Beispiel:
```Python hl_lines="6 11"
{!../../../docs_src/conditional_openapi/tutorial001.py!}
{!../../docs_src/conditional_openapi/tutorial001.py!}
```
Hier deklarieren wir die Einstellung `openapi_url` mit dem gleichen Defaultwert `"/openapi.json"`.

View File

@@ -1,6 +1,6 @@
# Swagger-Oberfläche konfigurieren
Sie können einige zusätzliche <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration" class="external-link" target="_blank">Parameter der Swagger-Oberfläche</a> konfigurieren.
Sie können einige zusätzliche <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/" class="external-link" target="_blank">Parameter der Swagger-Oberfläche</a> konfigurieren.
Um diese zu konfigurieren, übergeben Sie das Argument `swagger_ui_parameters` beim Erstellen des `FastAPI()`-App-Objekts oder an die Funktion `get_swagger_ui_html()`.
@@ -19,7 +19,7 @@ Ohne Änderung der Einstellungen ist die Syntaxhervorhebung standardmäßig akti
Sie können sie jedoch deaktivieren, indem Sie `syntaxHighlight` auf `False` setzen:
```Python hl_lines="3"
{!../../../docs_src/configure_swagger_ui/tutorial001.py!}
{!../../docs_src/configure_swagger_ui/tutorial001.py!}
```
... und dann zeigt die Swagger-Oberfläche die Syntaxhervorhebung nicht mehr an:
@@ -31,7 +31,7 @@ Sie können sie jedoch deaktivieren, indem Sie `syntaxHighlight` auf `False` set
Auf die gleiche Weise könnten Sie das Theme der Syntaxhervorhebung mit dem Schlüssel `syntaxHighlight.theme` festlegen (beachten Sie, dass er einen Punkt in der Mitte hat):
```Python hl_lines="3"
{!../../../docs_src/configure_swagger_ui/tutorial002.py!}
{!../../docs_src/configure_swagger_ui/tutorial002.py!}
```
Obige Konfiguration würde das Theme für die Farbe der Syntaxhervorhebung ändern:
@@ -45,7 +45,7 @@ FastAPI enthält einige Defaultkonfigurationsparameter, die für die meisten Anw
Es umfasst die folgenden Defaultkonfigurationen:
```Python
{!../../../fastapi/openapi/docs.py[ln:7-23]!}
{!../../fastapi/openapi/docs.py[ln:7-23]!}
```
Sie können jede davon überschreiben, indem Sie im Argument `swagger_ui_parameters` einen anderen Wert festlegen.
@@ -53,12 +53,12 @@ Sie können jede davon überschreiben, indem Sie im Argument `swagger_ui_paramet
Um beispielsweise `deepLinking` zu deaktivieren, könnten Sie folgende Einstellungen an `swagger_ui_parameters` übergeben:
```Python hl_lines="3"
{!../../../docs_src/configure_swagger_ui/tutorial003.py!}
{!../../docs_src/configure_swagger_ui/tutorial003.py!}
```
## Andere Parameter der Swagger-Oberfläche
Um alle anderen möglichen Konfigurationen zu sehen, die Sie verwenden können, lesen Sie die offizielle <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration" class="external-link" target="_blank">Dokumentation für die Parameter der Swagger-Oberfläche</a>.
Um alle anderen möglichen Konfigurationen zu sehen, die Sie verwenden können, lesen Sie die offizielle <a href="https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/" class="external-link" target="_blank">Dokumentation für die Parameter der Swagger-Oberfläche</a>.
## JavaScript-basierte Einstellungen

View File

@@ -19,7 +19,7 @@ Der erste Schritt besteht darin, die automatischen Dokumentationen zu deaktivier
Um diese zu deaktivieren, setzen Sie deren URLs beim Erstellen Ihrer `FastAPI`-App auf `None`:
```Python hl_lines="8"
{!../../../docs_src/custom_docs_ui/tutorial001.py!}
{!../../docs_src/custom_docs_ui/tutorial001.py!}
```
### Die benutzerdefinierten Dokumentationen hinzufügen
@@ -37,7 +37,7 @@ Sie können die internen Funktionen von FastAPI wiederverwenden, um die HTML-Sei
Und genau so für ReDoc ...
```Python hl_lines="2-6 11-19 22-24 27-33"
{!../../../docs_src/custom_docs_ui/tutorial001.py!}
{!../../docs_src/custom_docs_ui/tutorial001.py!}
```
/// tip | "Tipp"
@@ -55,7 +55,7 @@ Swagger UI erledigt das hinter den Kulissen für Sie, benötigt aber diesen „U
Um nun testen zu können, ob alles funktioniert, erstellen Sie eine *Pfadoperation*:
```Python hl_lines="36-38"
{!../../../docs_src/custom_docs_ui/tutorial001.py!}
{!../../docs_src/custom_docs_ui/tutorial001.py!}
```
### Es ausprobieren
@@ -125,7 +125,7 @@ Danach könnte Ihre Dateistruktur wie folgt aussehen:
* „Mounten“ Sie eine `StaticFiles()`-Instanz in einem bestimmten Pfad.
```Python hl_lines="7 11"
{!../../../docs_src/custom_docs_ui/tutorial002.py!}
{!../../docs_src/custom_docs_ui/tutorial002.py!}
```
### Die statischen Dateien testen
@@ -159,7 +159,7 @@ Wie bei der Verwendung eines benutzerdefinierten CDN besteht der erste Schritt d
Um diese zu deaktivieren, setzen Sie deren URLs beim Erstellen Ihrer `FastAPI`-App auf `None`:
```Python hl_lines="9"
{!../../../docs_src/custom_docs_ui/tutorial002.py!}
{!../../docs_src/custom_docs_ui/tutorial002.py!}
```
### Die benutzerdefinierten Dokumentationen, mit statischen Dateien, hinzufügen
@@ -177,7 +177,7 @@ Auch hier können Sie die internen Funktionen von FastAPI wiederverwenden, um di
Und genau so für ReDoc ...
```Python hl_lines="2-6 14-22 25-27 30-36"
{!../../../docs_src/custom_docs_ui/tutorial002.py!}
{!../../docs_src/custom_docs_ui/tutorial002.py!}
```
/// tip | "Tipp"
@@ -195,7 +195,7 @@ Swagger UI erledigt das hinter den Kulissen für Sie, benötigt aber diesen „U
Um nun testen zu können, ob alles funktioniert, erstellen Sie eine *Pfadoperation*:
```Python hl_lines="39-41"
{!../../../docs_src/custom_docs_ui/tutorial002.py!}
{!../../docs_src/custom_docs_ui/tutorial002.py!}
```
### Benutzeroberfläche, mit statischen Dateien, testen

View File

@@ -43,7 +43,7 @@ Wenn der Header kein `gzip` enthält, wird nicht versucht, den Body zu dekomprim
Auf diese Weise kann dieselbe Routenklasse gzip-komprimierte oder unkomprimierte Requests verarbeiten.
```Python hl_lines="8-15"
{!../../../docs_src/custom_request_and_route/tutorial001.py!}
{!../../docs_src/custom_request_and_route/tutorial001.py!}
```
### Eine benutzerdefinierte `GzipRoute`-Klasse erstellen
@@ -57,7 +57,7 @@ Diese Methode gibt eine Funktion zurück. Und diese Funktion empfängt einen Req
Hier verwenden wir sie, um aus dem ursprünglichen Request einen `GzipRequest` zu erstellen.
```Python hl_lines="18-26"
{!../../../docs_src/custom_request_and_route/tutorial001.py!}
{!../../docs_src/custom_request_and_route/tutorial001.py!}
```
/// note | "Technische Details"
@@ -97,13 +97,13 @@ Wir können denselben Ansatz auch verwenden, um in einem Exceptionhandler auf de
Alles, was wir tun müssen, ist, den Request innerhalb eines `try`/`except`-Blocks zu handhaben:
```Python hl_lines="13 15"
{!../../../docs_src/custom_request_and_route/tutorial002.py!}
{!../../docs_src/custom_request_and_route/tutorial002.py!}
```
Wenn eine Exception auftritt, befindet sich die `Request`-Instanz weiterhin im Gültigkeitsbereich, sodass wir den Requestbody lesen und bei der Fehlerbehandlung verwenden können:
```Python hl_lines="16-18"
{!../../../docs_src/custom_request_and_route/tutorial002.py!}
{!../../docs_src/custom_request_and_route/tutorial002.py!}
```
## Benutzerdefinierte `APIRoute`-Klasse in einem Router
@@ -111,11 +111,11 @@ Wenn eine Exception auftritt, befindet sich die `Request`-Instanz weiterhin im G
Sie können auch den Parameter `route_class` eines `APIRouter` festlegen:
```Python hl_lines="26"
{!../../../docs_src/custom_request_and_route/tutorial003.py!}
{!../../docs_src/custom_request_and_route/tutorial003.py!}
```
In diesem Beispiel verwenden die *Pfadoperationen* unter dem `router` die benutzerdefinierte `TimedRoute`-Klasse und haben in der Response einen zusätzlichen `X-Response-Time`-Header mit der Zeit, die zum Generieren der Response benötigt wurde:
```Python hl_lines="13-20"
{!../../../docs_src/custom_request_and_route/tutorial003.py!}
{!../../docs_src/custom_request_and_route/tutorial003.py!}
```

View File

@@ -44,7 +44,7 @@ Fügen wir beispielsweise <a href="https://github.com/Rebilly/ReDoc/blob/master/
Schreiben Sie zunächst wie gewohnt Ihre ganze **FastAPI**-Anwendung:
```Python hl_lines="1 4 7-9"
{!../../../docs_src/extending_openapi/tutorial001.py!}
{!../../docs_src/extending_openapi/tutorial001.py!}
```
### Das OpenAPI-Schema generieren
@@ -52,7 +52,7 @@ Schreiben Sie zunächst wie gewohnt Ihre ganze **FastAPI**-Anwendung:
Verwenden Sie dann dieselbe Hilfsfunktion, um das OpenAPI-Schema innerhalb einer `custom_openapi()`-Funktion zu generieren:
```Python hl_lines="2 15-21"
{!../../../docs_src/extending_openapi/tutorial001.py!}
{!../../docs_src/extending_openapi/tutorial001.py!}
```
### Das OpenAPI-Schema ändern
@@ -60,7 +60,7 @@ Verwenden Sie dann dieselbe Hilfsfunktion, um das OpenAPI-Schema innerhalb einer
Jetzt können Sie die ReDoc-Erweiterung hinzufügen und dem `info`-„Objekt“ im OpenAPI-Schema ein benutzerdefiniertes `x-logo` hinzufügen:
```Python hl_lines="22-24"
{!../../../docs_src/extending_openapi/tutorial001.py!}
{!../../docs_src/extending_openapi/tutorial001.py!}
```
### Zwischenspeichern des OpenAPI-Schemas
@@ -72,7 +72,7 @@ Auf diese Weise muss Ihre Anwendung das Schema nicht jedes Mal generieren, wenn
Es wird nur einmal generiert und dann wird dasselbe zwischengespeicherte Schema für die nächsten Requests verwendet.
```Python hl_lines="13-14 25-26"
{!../../../docs_src/extending_openapi/tutorial001.py!}
{!../../docs_src/extending_openapi/tutorial001.py!}
```
### Die Methode überschreiben
@@ -80,7 +80,7 @@ Es wird nur einmal generiert und dann wird dasselbe zwischengespeicherte Schema
Jetzt können Sie die Methode `.openapi()` durch Ihre neue Funktion ersetzen.
```Python hl_lines="29"
{!../../../docs_src/extending_openapi/tutorial001.py!}
{!../../docs_src/extending_openapi/tutorial001.py!}
```
### Testen

View File

@@ -36,7 +36,7 @@ Abhängig von Ihrem Anwendungsfall bevorzugen Sie vielleicht eine andere Bibliot
Hier ist eine kleine Vorschau, wie Sie Strawberry mit FastAPI integrieren können:
```Python hl_lines="3 22 25-26"
{!../../../docs_src/graphql/tutorial001.py!}
{!../../docs_src/graphql/tutorial001.py!}
```
Weitere Informationen zu Strawberry finden Sie in der <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry-Dokumentation</a>.

View File

@@ -13,7 +13,7 @@ Nehmen wir an, Sie haben ein Pydantic-Modell mit Defaultwerten wie dieses:
//// tab | Python 3.10+
```Python hl_lines="7"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py310.py[ln:1-7]!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py310.py[ln:1-7]!}
# Code unterhalb weggelassen 👇
```
@@ -22,7 +22,7 @@ Nehmen wir an, Sie haben ein Pydantic-Modell mit Defaultwerten wie dieses:
<summary>👀 Vollständige Dateivorschau</summary>
```Python
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py310.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py310.py!}
```
</details>
@@ -32,7 +32,7 @@ Nehmen wir an, Sie haben ein Pydantic-Modell mit Defaultwerten wie dieses:
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py[ln:1-9]!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py39.py[ln:1-9]!}
# Code unterhalb weggelassen 👇
```
@@ -41,7 +41,7 @@ Nehmen wir an, Sie haben ein Pydantic-Modell mit Defaultwerten wie dieses:
<summary>👀 Vollständige Dateivorschau</summary>
```Python
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
```
</details>
@@ -51,7 +51,7 @@ Nehmen wir an, Sie haben ein Pydantic-Modell mit Defaultwerten wie dieses:
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-9]!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-9]!}
# Code unterhalb weggelassen 👇
```
@@ -60,7 +60,7 @@ Nehmen wir an, Sie haben ein Pydantic-Modell mit Defaultwerten wie dieses:
<summary>👀 Vollständige Dateivorschau</summary>
```Python
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001.py!}
```
</details>
@@ -74,7 +74,7 @@ Wenn Sie dieses Modell wie hier als Eingabe verwenden:
//// tab | Python 3.10+
```Python hl_lines="14"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py310.py[ln:1-15]!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py310.py[ln:1-15]!}
# Code unterhalb weggelassen 👇
```
@@ -83,7 +83,7 @@ Wenn Sie dieses Modell wie hier als Eingabe verwenden:
<summary>👀 Vollständige Dateivorschau</summary>
```Python
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py310.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py310.py!}
```
</details>
@@ -93,7 +93,7 @@ Wenn Sie dieses Modell wie hier als Eingabe verwenden:
//// tab | Python 3.9+
```Python hl_lines="16"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py[ln:1-17]!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py39.py[ln:1-17]!}
# Code unterhalb weggelassen 👇
```
@@ -102,7 +102,7 @@ Wenn Sie dieses Modell wie hier als Eingabe verwenden:
<summary>👀 Vollständige Dateivorschau</summary>
```Python
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
```
</details>
@@ -112,7 +112,7 @@ Wenn Sie dieses Modell wie hier als Eingabe verwenden:
//// tab | Python 3.8+
```Python hl_lines="16"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-17]!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-17]!}
# Code unterhalb weggelassen 👇
```
@@ -121,7 +121,7 @@ Wenn Sie dieses Modell wie hier als Eingabe verwenden:
<summary>👀 Vollständige Dateivorschau</summary>
```Python
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001.py!}
```
</details>
@@ -145,7 +145,7 @@ Wenn Sie jedoch dasselbe Modell als Ausgabe verwenden, wie hier:
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py310.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py310.py!}
```
////
@@ -153,7 +153,7 @@ Wenn Sie jedoch dasselbe Modell als Ausgabe verwenden, wie hier:
//// tab | Python 3.9+
```Python hl_lines="21"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
```
////
@@ -161,7 +161,7 @@ Wenn Sie jedoch dasselbe Modell als Ausgabe verwenden, wie hier:
//// tab | Python 3.8+
```Python hl_lines="21"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial001.py!}
```
////
@@ -226,7 +226,7 @@ Unterstützung für `separate_input_output_schemas` wurde in FastAPI `0.102.0` h
//// tab | Python 3.10+
```Python hl_lines="10"
{!> ../../../docs_src/separate_openapi_schemas/tutorial002_py310.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial002_py310.py!}
```
////
@@ -234,7 +234,7 @@ Unterstützung für `separate_input_output_schemas` wurde in FastAPI `0.102.0` h
//// tab | Python 3.9+
```Python hl_lines="12"
{!> ../../../docs_src/separate_openapi_schemas/tutorial002_py39.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial002_py39.py!}
```
////
@@ -242,7 +242,7 @@ Unterstützung für `separate_input_output_schemas` wurde in FastAPI `0.102.0` h
//// tab | Python 3.8+
```Python hl_lines="12"
{!> ../../../docs_src/separate_openapi_schemas/tutorial002.py!}
{!> ../../docs_src/separate_openapi_schemas/tutorial002.py!}
```
////

View File

@@ -449,7 +449,7 @@ Um mehr darüber zu erfahren, siehe den Abschnitt <a href="https://fastapi.tiang
Wird von Pydantic verwendet:
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - für E-Mail-Validierung.
* <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email-validator</code></a> - für E-Mail-Validierung.
* <a href="https://docs.pydantic.dev/latest/usage/pydantic_settings/" target="_blank"><code>pydantic-settings</code></a> - für die Verwaltung von Einstellungen.
* <a href="https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/" target="_blank"><code>pydantic-extra-types</code></a> - für zusätzliche Typen, mit Pydantic zu verwenden.

View File

@@ -23,7 +23,7 @@ Wenn Sie ein Python-Experte sind und bereits alles über Typhinweise wissen, üb
Fangen wir mit einem einfachen Beispiel an:
```Python
{!../../../docs_src/python_types/tutorial001.py!}
{!../../docs_src/python_types/tutorial001.py!}
```
Dieses Programm gibt aus:
@@ -39,7 +39,7 @@ Die Funktion macht Folgendes:
* <abbr title="Füge zu einer Einheit zusammen, eins nach dem anderen.">Verkettet</abbr> sie mit einem Leerzeichen in der Mitte.
```Python hl_lines="2"
{!../../../docs_src/python_types/tutorial001.py!}
{!../../docs_src/python_types/tutorial001.py!}
```
### Bearbeiten Sie es
@@ -83,7 +83,7 @@ Das war's.
Das sind die „Typhinweise“:
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial002.py!}
{!../../docs_src/python_types/tutorial002.py!}
```
Das ist nicht das gleiche wie das Deklarieren von Defaultwerten, wie es hier der Fall ist:
@@ -113,7 +113,7 @@ Hier können Sie durch die Optionen blättern, bis Sie diejenige finden, bei der
Sehen Sie sich diese Funktion an, sie hat bereits Typhinweise:
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial003.py!}
{!../../docs_src/python_types/tutorial003.py!}
```
Da der Editor die Typen der Variablen kennt, erhalten Sie nicht nur Code-Vervollständigung, sondern auch eine Fehlerprüfung:
@@ -123,7 +123,7 @@ Da der Editor die Typen der Variablen kennt, erhalten Sie nicht nur Code-Vervoll
Jetzt, da Sie wissen, dass Sie das reparieren müssen, konvertieren Sie `age` mittels `str(age)` in einen String:
```Python hl_lines="2"
{!../../../docs_src/python_types/tutorial004.py!}
{!../../docs_src/python_types/tutorial004.py!}
```
## Deklarieren von Typen
@@ -144,7 +144,7 @@ Zum Beispiel diese:
* `bytes`
```Python hl_lines="1"
{!../../../docs_src/python_types/tutorial005.py!}
{!../../docs_src/python_types/tutorial005.py!}
```
### Generische Typen mit Typ-Parametern
@@ -182,7 +182,7 @@ Als Typ nehmen Sie `list`.
Da die Liste ein Typ ist, welcher innere Typen enthält, werden diese von eckigen Klammern umfasst:
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial006_py39.py!}
{!> ../../docs_src/python_types/tutorial006_py39.py!}
```
////
@@ -192,7 +192,7 @@ Da die Liste ein Typ ist, welcher innere Typen enthält, werden diese von eckige
Von `typing` importieren Sie `List` (mit Großbuchstaben `L`):
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial006.py!}
{!> ../../docs_src/python_types/tutorial006.py!}
```
Deklarieren Sie die Variable mit der gleichen Doppelpunkt-Syntax (`:`).
@@ -202,7 +202,7 @@ Als Typ nehmen Sie das `List`, das Sie von `typing` importiert haben.
Da die Liste ein Typ ist, welcher innere Typen enthält, werden diese von eckigen Klammern umfasst:
```Python hl_lines="4"
{!> ../../../docs_src/python_types/tutorial006.py!}
{!> ../../docs_src/python_types/tutorial006.py!}
```
////
@@ -240,7 +240,7 @@ Das Gleiche gilt für die Deklaration eines Tupels `tuple` und einer Men
//// tab | Python 3.9+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial007_py39.py!}
{!> ../../docs_src/python_types/tutorial007_py39.py!}
```
////
@@ -248,7 +248,7 @@ Das Gleiche gilt für die Deklaration eines Tupels `tuple` und einer Men
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
{!> ../../docs_src/python_types/tutorial007.py!}
```
////
@@ -269,7 +269,7 @@ Der zweite Typ-Parameter ist für die Werte des `dict`:
//// tab | Python 3.9+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial008_py39.py!}
{!> ../../docs_src/python_types/tutorial008_py39.py!}
```
////
@@ -277,7 +277,7 @@ Der zweite Typ-Parameter ist für die Werte des `dict`:
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
{!> ../../docs_src/python_types/tutorial008.py!}
```
////
@@ -299,7 +299,7 @@ In Python 3.10 gibt es zusätzlich eine **neue Syntax**, die es erlaubt, die mö
//// tab | Python 3.10+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial008b_py310.py!}
{!> ../../docs_src/python_types/tutorial008b_py310.py!}
```
////
@@ -307,7 +307,7 @@ In Python 3.10 gibt es zusätzlich eine **neue Syntax**, die es erlaubt, die mö
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
{!> ../../docs_src/python_types/tutorial008b.py!}
```
////
@@ -321,7 +321,7 @@ Sie können deklarieren, dass ein Wert ein `str`, aber vielleicht auch `None` se
In Python 3.6 und darüber (inklusive Python 3.10) können Sie das deklarieren, indem Sie `Optional` vom `typing` Modul importieren und verwenden.
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009.py!}
{!../../docs_src/python_types/tutorial009.py!}
```
Wenn Sie `Optional[str]` anstelle von nur `str` verwenden, wird Ihr Editor Ihnen dabei helfen, Fehler zu erkennen, bei denen Sie annehmen könnten, dass ein Wert immer eine String (`str`) ist, obwohl er auch `None` sein könnte.
@@ -333,7 +333,7 @@ Das bedeutet auch, dass Sie in Python 3.10 `Something | None` verwenden können:
//// tab | Python 3.10+
```Python hl_lines="1"
{!> ../../../docs_src/python_types/tutorial009_py310.py!}
{!> ../../docs_src/python_types/tutorial009_py310.py!}
```
////
@@ -341,7 +341,7 @@ Das bedeutet auch, dass Sie in Python 3.10 `Something | None` verwenden können:
//// tab | Python 3.8+
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
{!> ../../docs_src/python_types/tutorial009.py!}
```
////
@@ -349,7 +349,7 @@ Das bedeutet auch, dass Sie in Python 3.10 `Something | None` verwenden können:
//// tab | Python 3.8+ Alternative
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
{!> ../../docs_src/python_types/tutorial009b.py!}
```
////
@@ -370,7 +370,7 @@ Es geht nur um Wörter und Namen. Aber diese Worte können beeinflussen, wie Sie
Nehmen wir zum Beispiel diese Funktion:
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009c.py!}
{!../../docs_src/python_types/tutorial009c.py!}
```
Der Parameter `name` ist definiert als `Optional[str]`, aber er ist **nicht optional**, Sie können die Funktion nicht ohne diesen Parameter aufrufen:
@@ -388,7 +388,7 @@ say_hi(name=None) # Das funktioniert, None is gültig 🎉
Die gute Nachricht ist, dass Sie sich darüber keine Sorgen mehr machen müssen, wenn Sie Python 3.10 verwenden, da Sie einfach `|` verwenden können, um Vereinigungen von Typen zu definieren:
```Python hl_lines="1 4"
{!../../../docs_src/python_types/tutorial009c_py310.py!}
{!../../docs_src/python_types/tutorial009c_py310.py!}
```
Und dann müssen Sie sich nicht mehr um Namen wie `Optional` und `Union` kümmern. 😎
@@ -452,13 +452,13 @@ Sie können auch eine Klasse als Typ einer Variablen deklarieren.
Nehmen wir an, Sie haben eine Klasse `Person`, mit einem Namen:
```Python hl_lines="1-3"
{!../../../docs_src/python_types/tutorial010.py!}
{!../../docs_src/python_types/tutorial010.py!}
```
Dann können Sie eine Variable vom Typ `Person` deklarieren:
```Python hl_lines="6"
{!../../../docs_src/python_types/tutorial010.py!}
{!../../docs_src/python_types/tutorial010.py!}
```
Und wiederum bekommen Sie die volle Editor-Unterstützung:
@@ -486,7 +486,7 @@ Ein Beispiel aus der offiziellen Pydantic Dokumentation:
//// tab | Python 3.10+
```Python
{!> ../../../docs_src/python_types/tutorial011_py310.py!}
{!> ../../docs_src/python_types/tutorial011_py310.py!}
```
////
@@ -494,7 +494,7 @@ Ein Beispiel aus der offiziellen Pydantic Dokumentation:
//// tab | Python 3.9+
```Python
{!> ../../../docs_src/python_types/tutorial011_py39.py!}
{!> ../../docs_src/python_types/tutorial011_py39.py!}
```
////
@@ -502,7 +502,7 @@ Ein Beispiel aus der offiziellen Pydantic Dokumentation:
//// tab | Python 3.8+
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}
{!> ../../docs_src/python_types/tutorial011.py!}
```
////
@@ -532,7 +532,7 @@ Python bietet auch die Möglichkeit, **zusätzliche Metadaten** in Typhinweisen
In Python 3.9 ist `Annotated` ein Teil der Standardbibliothek, Sie können es von `typing` importieren.
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial013_py39.py!}
{!> ../../docs_src/python_types/tutorial013_py39.py!}
```
////
@@ -544,7 +544,7 @@ In Versionen niedriger als Python 3.9 importieren Sie `Annotated` von `typing_ex
Es wird bereits mit **FastAPI** installiert sein.
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial013.py!}
{!> ../../docs_src/python_types/tutorial013.py!}
```
////

View File

@@ -16,7 +16,7 @@ Hierzu zählen beispielsweise:
Importieren Sie zunächst `BackgroundTasks` und definieren Sie einen Parameter in Ihrer *Pfadoperation-Funktion* mit der Typdeklaration `BackgroundTasks`:
```Python hl_lines="1 13"
{!../../../docs_src/background_tasks/tutorial001.py!}
{!../../docs_src/background_tasks/tutorial001.py!}
```
**FastAPI** erstellt für Sie das Objekt vom Typ `BackgroundTasks` und übergibt es als diesen Parameter.
@@ -34,7 +34,7 @@ In diesem Fall schreibt die Taskfunktion in eine Datei (den Versand einer E-Mail
Und da der Schreibvorgang nicht `async` und `await` verwendet, definieren wir die Funktion mit normalem `def`:
```Python hl_lines="6-9"
{!../../../docs_src/background_tasks/tutorial001.py!}
{!../../docs_src/background_tasks/tutorial001.py!}
```
## Den Hintergrundtask hinzufügen
@@ -42,7 +42,7 @@ Und da der Schreibvorgang nicht `async` und `await` verwendet, definieren wir di
Übergeben Sie innerhalb Ihrer *Pfadoperation-Funktion* Ihre Taskfunktion mit der Methode `.add_task()` an das *Hintergrundtasks*-Objekt:
```Python hl_lines="14"
{!../../../docs_src/background_tasks/tutorial001.py!}
{!../../docs_src/background_tasks/tutorial001.py!}
```
`.add_task()` erhält als Argumente:
@@ -60,7 +60,7 @@ Die Verwendung von `BackgroundTasks` funktioniert auch mit dem <abbr title="Einb
//// tab | Python 3.10+
```Python hl_lines="13 15 22 25"
{!> ../../../docs_src/background_tasks/tutorial002_an_py310.py!}
{!> ../../docs_src/background_tasks/tutorial002_an_py310.py!}
```
////
@@ -68,7 +68,7 @@ Die Verwendung von `BackgroundTasks` funktioniert auch mit dem <abbr title="Einb
//// tab | Python 3.9+
```Python hl_lines="13 15 22 25"
{!> ../../../docs_src/background_tasks/tutorial002_an_py39.py!}
{!> ../../docs_src/background_tasks/tutorial002_an_py39.py!}
```
////
@@ -76,7 +76,7 @@ Die Verwendung von `BackgroundTasks` funktioniert auch mit dem <abbr title="Einb
//// tab | Python 3.8+
```Python hl_lines="14 16 23 26"
{!> ../../../docs_src/background_tasks/tutorial002_an.py!}
{!> ../../docs_src/background_tasks/tutorial002_an.py!}
```
////
@@ -90,7 +90,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11 13 20 23"
{!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
{!> ../../docs_src/background_tasks/tutorial002_py310.py!}
```
////
@@ -104,7 +104,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="13 15 22 25"
{!> ../../../docs_src/background_tasks/tutorial002.py!}
{!> ../../docs_src/background_tasks/tutorial002.py!}
```
////

View File

@@ -86,7 +86,7 @@ Sie können die *Pfadoperationen* für dieses Modul mit `APIRouter` erstellen.
Sie importieren ihn und erstellen eine „Instanz“ auf die gleiche Weise wie mit der Klasse `FastAPI`:
```Python hl_lines="1 3" title="app/routers/users.py"
{!../../../docs_src/bigger_applications/app/routers/users.py!}
{!../../docs_src/bigger_applications/app/routers/users.py!}
```
### *Pfadoperationen* mit `APIRouter`
@@ -96,7 +96,7 @@ Und dann verwenden Sie ihn, um Ihre *Pfadoperationen* zu deklarieren.
Verwenden Sie ihn auf die gleiche Weise wie die Klasse `FastAPI`:
```Python hl_lines="6 11 16" title="app/routers/users.py"
{!../../../docs_src/bigger_applications/app/routers/users.py!}
{!../../docs_src/bigger_applications/app/routers/users.py!}
```
Sie können sich `APIRouter` als eine „Mini-`FastAPI`“-Klasse vorstellen.
@@ -124,7 +124,7 @@ Wir werden nun eine einfache Abhängigkeit verwenden, um einen benutzerdefiniert
//// tab | Python 3.9+
```Python hl_lines="3 6-8" title="app/dependencies.py"
{!> ../../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
{!> ../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
```
////
@@ -132,7 +132,7 @@ Wir werden nun eine einfache Abhängigkeit verwenden, um einen benutzerdefiniert
//// tab | Python 3.8+
```Python hl_lines="1 5-7" title="app/dependencies.py"
{!> ../../../docs_src/bigger_applications/app_an/dependencies.py!}
{!> ../../docs_src/bigger_applications/app_an/dependencies.py!}
```
////
@@ -146,7 +146,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1 4-6" title="app/dependencies.py"
{!> ../../../docs_src/bigger_applications/app/dependencies.py!}
{!> ../../docs_src/bigger_applications/app/dependencies.py!}
```
////
@@ -182,7 +182,7 @@ Wir wissen, dass alle *Pfadoperationen* in diesem Modul folgendes haben:
Anstatt also alles zu jeder *Pfadoperation* hinzuzufügen, können wir es dem `APIRouter` hinzufügen.
```Python hl_lines="5-10 16 21" title="app/routers/items.py"
{!../../../docs_src/bigger_applications/app/routers/items.py!}
{!../../docs_src/bigger_applications/app/routers/items.py!}
```
Da der Pfad jeder *Pfadoperation* mit `/` beginnen muss, wie in:
@@ -243,7 +243,7 @@ Und wir müssen die Abhängigkeitsfunktion aus dem Modul `app.dependencies` impo
Daher verwenden wir einen relativen Import mit `..` für die Abhängigkeiten:
```Python hl_lines="3" title="app/routers/items.py"
{!../../../docs_src/bigger_applications/app/routers/items.py!}
{!../../docs_src/bigger_applications/app/routers/items.py!}
```
#### Wie relative Importe funktionieren
@@ -316,7 +316,7 @@ Wir fügen weder das Präfix `/items` noch `tags=["items"]` zu jeder *Pfadoperat
Aber wir können immer noch _mehr_ `tags` hinzufügen, die auf eine bestimmte *Pfadoperation* angewendet werden, sowie einige zusätzliche `responses`, die speziell für diese *Pfadoperation* gelten:
```Python hl_lines="30-31" title="app/routers/items.py"
{!../../../docs_src/bigger_applications/app/routers/items.py!}
{!../../docs_src/bigger_applications/app/routers/items.py!}
```
/// tip | "Tipp"
@@ -344,7 +344,7 @@ Sie importieren und erstellen wie gewohnt eine `FastAPI`-Klasse.
Und wir können sogar [globale Abhängigkeiten](dependencies/global-dependencies.md){.internal-link target=_blank} deklarieren, die mit den Abhängigkeiten für jeden `APIRouter` kombiniert werden:
```Python hl_lines="1 3 7" title="app/main.py"
{!../../../docs_src/bigger_applications/app/main.py!}
{!../../docs_src/bigger_applications/app/main.py!}
```
### Den `APIRouter` importieren
@@ -352,7 +352,7 @@ Und wir können sogar [globale Abhängigkeiten](dependencies/global-dependencies
Jetzt importieren wir die anderen Submodule, die `APIRouter` haben:
```Python hl_lines="4-5" title="app/main.py"
{!../../../docs_src/bigger_applications/app/main.py!}
{!../../docs_src/bigger_applications/app/main.py!}
```
Da es sich bei den Dateien `app/routers/users.py` und `app/routers/items.py` um Submodule handelt, die Teil desselben Python-Packages `app` sind, können wir einen einzelnen Punkt `.` verwenden, um sie mit „relativen Imports“ zu importieren.
@@ -417,7 +417,7 @@ würde der `router` von `users` den von `items` überschreiben und wir könnten
Um also beide in derselben Datei verwenden zu können, importieren wir die Submodule direkt:
```Python hl_lines="5" title="app/main.py"
{!../../../docs_src/bigger_applications/app/main.py!}
{!../../docs_src/bigger_applications/app/main.py!}
```
@@ -426,7 +426,7 @@ Um also beide in derselben Datei verwenden zu können, importieren wir die Submo
Inkludieren wir nun die `router` aus diesen Submodulen `users` und `items`:
```Python hl_lines="10-11" title="app/main.py"
{!../../../docs_src/bigger_applications/app/main.py!}
{!../../docs_src/bigger_applications/app/main.py!}
```
/// info
@@ -468,7 +468,7 @@ Sie enthält einen `APIRouter` mit einigen administrativen *Pfadoperationen*, di
In diesem Beispiel wird es ganz einfach sein. Nehmen wir jedoch an, dass wir, da sie mit anderen Projekten in der Organisation geteilt wird, sie nicht ändern und kein `prefix`, `dependencies`, `tags`, usw. direkt zum `APIRouter` hinzufügen können:
```Python hl_lines="3" title="app/internal/admin.py"
{!../../../docs_src/bigger_applications/app/internal/admin.py!}
{!../../docs_src/bigger_applications/app/internal/admin.py!}
```
Aber wir möchten immer noch ein benutzerdefiniertes `prefix` festlegen, wenn wir den `APIRouter` einbinden, sodass alle seine *Pfadoperationen* mit `/admin` beginnen, wir möchten es mit den `dependencies` sichern, die wir bereits für dieses Projekt haben, und wir möchten `tags` und `responses` hinzufügen.
@@ -476,7 +476,7 @@ Aber wir möchten immer noch ein benutzerdefiniertes `prefix` festlegen, wenn wi
Wir können das alles deklarieren, ohne den ursprünglichen `APIRouter` ändern zu müssen, indem wir diese Parameter an `app.include_router()` übergeben:
```Python hl_lines="14-17" title="app/main.py"
{!../../../docs_src/bigger_applications/app/main.py!}
{!../../docs_src/bigger_applications/app/main.py!}
```
Auf diese Weise bleibt der ursprüngliche `APIRouter` unverändert, sodass wir dieselbe `app/internal/admin.py`-Datei weiterhin mit anderen Projekten in der Organisation teilen können.
@@ -499,7 +499,7 @@ Wir können *Pfadoperationen* auch direkt zur `FastAPI`-App hinzufügen.
Hier machen wir es ... nur um zu zeigen, dass wir es können 🤷:
```Python hl_lines="21-23" title="app/main.py"
{!../../../docs_src/bigger_applications/app/main.py!}
{!../../docs_src/bigger_applications/app/main.py!}
```
und es wird korrekt funktionieren, zusammen mit allen anderen *Pfadoperationen*, die mit `app.include_router()` hinzugefügt wurden.

View File

@@ -9,7 +9,7 @@ Importieren Sie es zuerst:
//// tab | Python 3.10+
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
{!> ../../docs_src/body_fields/tutorial001_an_py310.py!}
```
////
@@ -17,7 +17,7 @@ Importieren Sie es zuerst:
//// tab | Python 3.9+
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
{!> ../../docs_src/body_fields/tutorial001_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Importieren Sie es zuerst:
//// tab | Python 3.8+
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
{!> ../../docs_src/body_fields/tutorial001_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="2"
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
{!> ../../docs_src/body_fields/tutorial001_py310.py!}
```
////
@@ -53,7 +53,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001.py!}
{!> ../../docs_src/body_fields/tutorial001.py!}
```
////
@@ -71,7 +71,7 @@ Dann können Sie `Field` mit Modellattributen deklarieren:
//// tab | Python 3.10+
```Python hl_lines="11-14"
{!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
{!> ../../docs_src/body_fields/tutorial001_an_py310.py!}
```
////
@@ -79,7 +79,7 @@ Dann können Sie `Field` mit Modellattributen deklarieren:
//// tab | Python 3.9+
```Python hl_lines="11-14"
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
{!> ../../docs_src/body_fields/tutorial001_an_py39.py!}
```
////
@@ -87,7 +87,7 @@ Dann können Sie `Field` mit Modellattributen deklarieren:
//// tab | Python 3.8+
```Python hl_lines="12-15"
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
{!> ../../docs_src/body_fields/tutorial001_an.py!}
```
////
@@ -101,7 +101,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9-12"
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
{!> ../../docs_src/body_fields/tutorial001_py310.py!}
```
////
@@ -115,7 +115,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11-14"
{!> ../../../docs_src/body_fields/tutorial001.py!}
{!> ../../docs_src/body_fields/tutorial001.py!}
```
////

View File

@@ -11,7 +11,7 @@ Und Sie können auch Body-Parameter als optional kennzeichnen, indem Sie den Def
//// tab | Python 3.10+
```Python hl_lines="18-20"
{!> ../../../docs_src/body_multiple_params/tutorial001_an_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial001_an_py310.py!}
```
////
@@ -19,7 +19,7 @@ Und Sie können auch Body-Parameter als optional kennzeichnen, indem Sie den Def
//// tab | Python 3.9+
```Python hl_lines="18-20"
{!> ../../../docs_src/body_multiple_params/tutorial001_an_py39.py!}
{!> ../../docs_src/body_multiple_params/tutorial001_an_py39.py!}
```
////
@@ -27,7 +27,7 @@ Und Sie können auch Body-Parameter als optional kennzeichnen, indem Sie den Def
//// tab | Python 3.8+
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001_an.py!}
{!> ../../docs_src/body_multiple_params/tutorial001_an.py!}
```
////
@@ -41,7 +41,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17-19"
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
////
@@ -55,7 +55,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001.py!}
{!> ../../docs_src/body_multiple_params/tutorial001.py!}
```
////
@@ -84,7 +84,7 @@ Aber Sie können auch mehrere Body-Parameter deklarieren, z. B. `item` und `user
//// tab | Python 3.10+
```Python hl_lines="20"
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
////
@@ -92,7 +92,7 @@ Aber Sie können auch mehrere Body-Parameter deklarieren, z. B. `item` und `user
//// tab | Python 3.8+
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
{!> ../../docs_src/body_multiple_params/tutorial002.py!}
```
////
@@ -139,7 +139,7 @@ Aber Sie können **FastAPI** instruieren, ihn als weiteren Body-Schlüssel zu er
//// tab | Python 3.10+
```Python hl_lines="23"
{!> ../../../docs_src/body_multiple_params/tutorial003_an_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial003_an_py310.py!}
```
////
@@ -147,7 +147,7 @@ Aber Sie können **FastAPI** instruieren, ihn als weiteren Body-Schlüssel zu er
//// tab | Python 3.9+
```Python hl_lines="23"
{!> ../../../docs_src/body_multiple_params/tutorial003_an_py39.py!}
{!> ../../docs_src/body_multiple_params/tutorial003_an_py39.py!}
```
////
@@ -155,7 +155,7 @@ Aber Sie können **FastAPI** instruieren, ihn als weiteren Body-Schlüssel zu er
//// tab | Python 3.8+
```Python hl_lines="24"
{!> ../../../docs_src/body_multiple_params/tutorial003_an.py!}
{!> ../../docs_src/body_multiple_params/tutorial003_an.py!}
```
////
@@ -169,7 +169,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="20"
{!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial003_py310.py!}
```
////
@@ -183,7 +183,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial003.py!}
{!> ../../docs_src/body_multiple_params/tutorial003.py!}
```
////
@@ -229,7 +229,7 @@ Zum Beispiel:
//// tab | Python 3.10+
```Python hl_lines="27"
{!> ../../../docs_src/body_multiple_params/tutorial004_an_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial004_an_py310.py!}
```
////
@@ -237,7 +237,7 @@ Zum Beispiel:
//// tab | Python 3.9+
```Python hl_lines="27"
{!> ../../../docs_src/body_multiple_params/tutorial004_an_py39.py!}
{!> ../../docs_src/body_multiple_params/tutorial004_an_py39.py!}
```
////
@@ -245,7 +245,7 @@ Zum Beispiel:
//// tab | Python 3.8+
```Python hl_lines="28"
{!> ../../../docs_src/body_multiple_params/tutorial004_an.py!}
{!> ../../docs_src/body_multiple_params/tutorial004_an.py!}
```
////
@@ -259,7 +259,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="25"
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
////
@@ -273,7 +273,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="27"
{!> ../../../docs_src/body_multiple_params/tutorial004.py!}
{!> ../../docs_src/body_multiple_params/tutorial004.py!}
```
////
@@ -301,7 +301,7 @@ so wie in:
//// tab | Python 3.10+
```Python hl_lines="17"
{!> ../../../docs_src/body_multiple_params/tutorial005_an_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial005_an_py310.py!}
```
////
@@ -309,7 +309,7 @@ so wie in:
//// tab | Python 3.9+
```Python hl_lines="17"
{!> ../../../docs_src/body_multiple_params/tutorial005_an_py39.py!}
{!> ../../docs_src/body_multiple_params/tutorial005_an_py39.py!}
```
////
@@ -317,7 +317,7 @@ so wie in:
//// tab | Python 3.8+
```Python hl_lines="18"
{!> ../../../docs_src/body_multiple_params/tutorial005_an.py!}
{!> ../../docs_src/body_multiple_params/tutorial005_an.py!}
```
////
@@ -331,7 +331,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="15"
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
{!> ../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
////
@@ -345,7 +345,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17"
{!> ../../../docs_src/body_multiple_params/tutorial005.py!}
{!> ../../docs_src/body_multiple_params/tutorial005.py!}
```
////

View File

@@ -9,7 +9,7 @@ Sie können ein Attribut als Kindtyp definieren, zum Beispiel eine Python-`list`
//// tab | Python 3.10+
```Python hl_lines="12"
{!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial001_py310.py!}
```
////
@@ -17,7 +17,7 @@ Sie können ein Attribut als Kindtyp definieren, zum Beispiel eine Python-`list`
//// tab | Python 3.8+
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial001.py!}
{!> ../../docs_src/body_nested_models/tutorial001.py!}
```
////
@@ -35,7 +35,7 @@ In Python 3.9 oder darüber können Sie einfach `list` verwenden, um diese Typan
In Python-Versionen vor 3.9 (3.6 und darüber), müssen Sie zuerst `List` von Pythons Standardmodul `typing` importieren.
```Python hl_lines="1"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
{!> ../../docs_src/body_nested_models/tutorial002.py!}
```
### Eine `list`e mit einem Typ-Parameter deklarieren
@@ -68,7 +68,7 @@ In unserem Beispiel können wir also bewirken, dass `tags` spezifisch eine „Li
//// tab | Python 3.10+
```Python hl_lines="12"
{!> ../../../docs_src/body_nested_models/tutorial002_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial002_py310.py!}
```
////
@@ -76,7 +76,7 @@ In unserem Beispiel können wir also bewirken, dass `tags` spezifisch eine „Li
//// tab | Python 3.9+
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial002_py39.py!}
```
////
@@ -84,7 +84,7 @@ In unserem Beispiel können wir also bewirken, dass `tags` spezifisch eine „Li
//// tab | Python 3.8+
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
{!> ../../docs_src/body_nested_models/tutorial002.py!}
```
////
@@ -100,7 +100,7 @@ Deklarieren wir also `tags` als Set von Strings.
//// tab | Python 3.10+
```Python hl_lines="12"
{!> ../../../docs_src/body_nested_models/tutorial003_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial003_py310.py!}
```
////
@@ -108,7 +108,7 @@ Deklarieren wir also `tags` als Set von Strings.
//// tab | Python 3.9+
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial003_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial003_py39.py!}
```
////
@@ -116,7 +116,7 @@ Deklarieren wir also `tags` als Set von Strings.
//// tab | Python 3.8+
```Python hl_lines="1 14"
{!> ../../../docs_src/body_nested_models/tutorial003.py!}
{!> ../../docs_src/body_nested_models/tutorial003.py!}
```
////
@@ -144,7 +144,7 @@ Wir können zum Beispiel ein `Image`-Modell definieren.
//// tab | Python 3.10+
```Python hl_lines="7-9"
{!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial004_py310.py!}
```
////
@@ -152,7 +152,7 @@ Wir können zum Beispiel ein `Image`-Modell definieren.
//// tab | Python 3.9+
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial004_py39.py!}
```
////
@@ -160,7 +160,7 @@ Wir können zum Beispiel ein `Image`-Modell definieren.
//// tab | Python 3.8+
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
{!> ../../docs_src/body_nested_models/tutorial004.py!}
```
////
@@ -172,7 +172,7 @@ Und dann können wir es als Typ eines Attributes verwenden.
//// tab | Python 3.10+
```Python hl_lines="18"
{!> ../../../docs_src/body_nested_models/tutorial004_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial004_py310.py!}
```
////
@@ -180,7 +180,7 @@ Und dann können wir es als Typ eines Attributes verwenden.
//// tab | Python 3.9+
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial004_py39.py!}
```
////
@@ -188,7 +188,7 @@ Und dann können wir es als Typ eines Attributes verwenden.
//// tab | Python 3.8+
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
{!> ../../docs_src/body_nested_models/tutorial004.py!}
```
////
@@ -227,7 +227,7 @@ Da wir zum Beispiel im `Image`-Modell ein Feld `url` haben, können wir deklarie
//// tab | Python 3.10+
```Python hl_lines="2 8"
{!> ../../../docs_src/body_nested_models/tutorial005_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial005_py310.py!}
```
////
@@ -235,7 +235,7 @@ Da wir zum Beispiel im `Image`-Modell ein Feld `url` haben, können wir deklarie
//// tab | Python 3.9+
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial005_py39.py!}
```
////
@@ -243,7 +243,7 @@ Da wir zum Beispiel im `Image`-Modell ein Feld `url` haben, können wir deklarie
//// tab | Python 3.8+
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005.py!}
{!> ../../docs_src/body_nested_models/tutorial005.py!}
```
////
@@ -257,7 +257,7 @@ Sie können Pydantic-Modelle auch als Typen innerhalb von `list`, `set`, usw. ve
//// tab | Python 3.10+
```Python hl_lines="18"
{!> ../../../docs_src/body_nested_models/tutorial006_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial006_py310.py!}
```
////
@@ -265,7 +265,7 @@ Sie können Pydantic-Modelle auch als Typen innerhalb von `list`, `set`, usw. ve
//// tab | Python 3.9+
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial006_py39.py!}
```
////
@@ -273,7 +273,7 @@ Sie können Pydantic-Modelle auch als Typen innerhalb von `list`, `set`, usw. ve
//// tab | Python 3.8+
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006.py!}
{!> ../../docs_src/body_nested_models/tutorial006.py!}
```
////
@@ -317,7 +317,7 @@ Sie können beliebig tief verschachtelte Modelle definieren:
//// tab | Python 3.10+
```Python hl_lines="7 12 18 21 25"
{!> ../../../docs_src/body_nested_models/tutorial007_py310.py!}
{!> ../../docs_src/body_nested_models/tutorial007_py310.py!}
```
////
@@ -325,7 +325,7 @@ Sie können beliebig tief verschachtelte Modelle definieren:
//// tab | Python 3.9+
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial007_py39.py!}
```
////
@@ -333,7 +333,7 @@ Sie können beliebig tief verschachtelte Modelle definieren:
//// tab | Python 3.8+
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007.py!}
{!> ../../docs_src/body_nested_models/tutorial007.py!}
```
////
@@ -363,7 +363,7 @@ so wie in:
//// tab | Python 3.9+
```Python hl_lines="13"
{!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial008_py39.py!}
```
////
@@ -371,7 +371,7 @@ so wie in:
//// tab | Python 3.8+
```Python hl_lines="15"
{!> ../../../docs_src/body_nested_models/tutorial008.py!}
{!> ../../docs_src/body_nested_models/tutorial008.py!}
```
////
@@ -407,7 +407,7 @@ Im folgenden Beispiel akzeptieren Sie irgendein `dict`, solange es `int`-Schlüs
//// tab | Python 3.9+
```Python hl_lines="7"
{!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
{!> ../../docs_src/body_nested_models/tutorial009_py39.py!}
```
////
@@ -415,7 +415,7 @@ Im folgenden Beispiel akzeptieren Sie irgendein `dict`, solange es `int`-Schlüs
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/body_nested_models/tutorial009.py!}
{!> ../../docs_src/body_nested_models/tutorial009.py!}
```
////

View File

@@ -9,7 +9,7 @@ Sie können den `jsonable_encoder` verwenden, um die empfangenen Daten in etwas
//// tab | Python 3.10+
```Python hl_lines="28-33"
{!> ../../../docs_src/body_updates/tutorial001_py310.py!}
{!> ../../docs_src/body_updates/tutorial001_py310.py!}
```
////
@@ -17,7 +17,7 @@ Sie können den `jsonable_encoder` verwenden, um die empfangenen Daten in etwas
//// tab | Python 3.9+
```Python hl_lines="30-35"
{!> ../../../docs_src/body_updates/tutorial001_py39.py!}
{!> ../../docs_src/body_updates/tutorial001_py39.py!}
```
////
@@ -25,7 +25,7 @@ Sie können den `jsonable_encoder` verwenden, um die empfangenen Daten in etwas
//// tab | Python 3.8+
```Python hl_lines="30-35"
{!> ../../../docs_src/body_updates/tutorial001.py!}
{!> ../../docs_src/body_updates/tutorial001.py!}
```
////
@@ -87,7 +87,7 @@ Sie können das verwenden, um ein `dict` zu erstellen, das nur die (im Request)
//// tab | Python 3.10+
```Python hl_lines="32"
{!> ../../../docs_src/body_updates/tutorial002_py310.py!}
{!> ../../docs_src/body_updates/tutorial002_py310.py!}
```
////
@@ -95,7 +95,7 @@ Sie können das verwenden, um ein `dict` zu erstellen, das nur die (im Request)
//// tab | Python 3.9+
```Python hl_lines="34"
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
{!> ../../docs_src/body_updates/tutorial002_py39.py!}
```
////
@@ -103,7 +103,7 @@ Sie können das verwenden, um ein `dict` zu erstellen, das nur die (im Request)
//// tab | Python 3.8+
```Python hl_lines="34"
{!> ../../../docs_src/body_updates/tutorial002.py!}
{!> ../../docs_src/body_updates/tutorial002.py!}
```
////
@@ -125,7 +125,7 @@ Wie in `stored_item_model.model_copy(update=update_data)`:
//// tab | Python 3.10+
```Python hl_lines="33"
{!> ../../../docs_src/body_updates/tutorial002_py310.py!}
{!> ../../docs_src/body_updates/tutorial002_py310.py!}
```
////
@@ -133,7 +133,7 @@ Wie in `stored_item_model.model_copy(update=update_data)`:
//// tab | Python 3.9+
```Python hl_lines="35"
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
{!> ../../docs_src/body_updates/tutorial002_py39.py!}
```
////
@@ -141,7 +141,7 @@ Wie in `stored_item_model.model_copy(update=update_data)`:
//// tab | Python 3.8+
```Python hl_lines="35"
{!> ../../../docs_src/body_updates/tutorial002.py!}
{!> ../../docs_src/body_updates/tutorial002.py!}
```
////
@@ -164,7 +164,7 @@ Zusammengefasst, um Teil-Ersetzungen vorzunehmen:
//// tab | Python 3.10+
```Python hl_lines="28-35"
{!> ../../../docs_src/body_updates/tutorial002_py310.py!}
{!> ../../docs_src/body_updates/tutorial002_py310.py!}
```
////
@@ -172,7 +172,7 @@ Zusammengefasst, um Teil-Ersetzungen vorzunehmen:
//// tab | Python 3.9+
```Python hl_lines="30-37"
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
{!> ../../docs_src/body_updates/tutorial002_py39.py!}
```
////
@@ -180,7 +180,7 @@ Zusammengefasst, um Teil-Ersetzungen vorzunehmen:
//// tab | Python 3.8+
```Python hl_lines="30-37"
{!> ../../../docs_src/body_updates/tutorial002.py!}
{!> ../../docs_src/body_updates/tutorial002.py!}
```
////

View File

@@ -25,7 +25,7 @@ Zuerst müssen Sie `BaseModel` von `pydantic` importieren:
//// tab | Python 3.10+
```Python hl_lines="2"
{!> ../../../docs_src/body/tutorial001_py310.py!}
{!> ../../docs_src/body/tutorial001_py310.py!}
```
////
@@ -33,7 +33,7 @@ Zuerst müssen Sie `BaseModel` von `pydantic` importieren:
//// tab | Python 3.8+
```Python hl_lines="4"
{!> ../../../docs_src/body/tutorial001.py!}
{!> ../../docs_src/body/tutorial001.py!}
```
////
@@ -47,7 +47,7 @@ Verwenden Sie Standard-Python-Typen für die Klassenattribute:
//// tab | Python 3.10+
```Python hl_lines="5-9"
{!> ../../../docs_src/body/tutorial001_py310.py!}
{!> ../../docs_src/body/tutorial001_py310.py!}
```
////
@@ -55,7 +55,7 @@ Verwenden Sie Standard-Python-Typen für die Klassenattribute:
//// tab | Python 3.8+
```Python hl_lines="7-11"
{!> ../../../docs_src/body/tutorial001.py!}
{!> ../../docs_src/body/tutorial001.py!}
```
////
@@ -89,7 +89,7 @@ Um es zu Ihrer *Pfadoperation* hinzuzufügen, deklarieren Sie es auf die gleiche
//// tab | Python 3.10+
```Python hl_lines="16"
{!> ../../../docs_src/body/tutorial001_py310.py!}
{!> ../../docs_src/body/tutorial001_py310.py!}
```
////
@@ -97,7 +97,7 @@ Um es zu Ihrer *Pfadoperation* hinzuzufügen, deklarieren Sie es auf die gleiche
//// tab | Python 3.8+
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial001.py!}
{!> ../../docs_src/body/tutorial001.py!}
```
////
@@ -170,7 +170,7 @@ Innerhalb der Funktion können Sie alle Attribute des Modells direkt verwenden:
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/body/tutorial002_py310.py!}
{!> ../../docs_src/body/tutorial002_py310.py!}
```
////
@@ -178,7 +178,7 @@ Innerhalb der Funktion können Sie alle Attribute des Modells direkt verwenden:
//// tab | Python 3.8+
```Python hl_lines="21"
{!> ../../../docs_src/body/tutorial002.py!}
{!> ../../docs_src/body/tutorial002.py!}
```
////
@@ -192,7 +192,7 @@ Sie können Pfad- und Requestbody-Parameter gleichzeitig deklarieren.
//// tab | Python 3.10+
```Python hl_lines="15-16"
{!> ../../../docs_src/body/tutorial003_py310.py!}
{!> ../../docs_src/body/tutorial003_py310.py!}
```
////
@@ -200,7 +200,7 @@ Sie können Pfad- und Requestbody-Parameter gleichzeitig deklarieren.
//// tab | Python 3.8+
```Python hl_lines="17-18"
{!> ../../../docs_src/body/tutorial003.py!}
{!> ../../docs_src/body/tutorial003.py!}
```
////
@@ -214,7 +214,7 @@ Sie können auch zur gleichen Zeit **Body-**, **Pfad-** und **Query-Parameter**
//// tab | Python 3.10+
```Python hl_lines="16"
{!> ../../../docs_src/body/tutorial004_py310.py!}
{!> ../../docs_src/body/tutorial004_py310.py!}
```
////
@@ -222,7 +222,7 @@ Sie können auch zur gleichen Zeit **Body-**, **Pfad-** und **Query-Parameter**
//// tab | Python 3.8+
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial004.py!}
{!> ../../docs_src/body/tutorial004.py!}
```
////

View File

@@ -9,7 +9,7 @@ Importieren Sie zuerst `Cookie`:
//// tab | Python 3.10+
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001_an_py310.py!}
{!> ../../docs_src/cookie_params/tutorial001_an_py310.py!}
```
////
@@ -17,7 +17,7 @@ Importieren Sie zuerst `Cookie`:
//// tab | Python 3.9+
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
{!> ../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Importieren Sie zuerst `Cookie`:
//// tab | Python 3.8+
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
{!> ../../docs_src/cookie_params/tutorial001_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
{!> ../../docs_src/cookie_params/tutorial001_py310.py!}
```
////
@@ -53,7 +53,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001.py!}
{!> ../../docs_src/cookie_params/tutorial001.py!}
```
////
@@ -67,7 +67,7 @@ Der erste Wert ist der Typ. Sie können `Cookie` die gehabten Extra Validierungs
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/cookie_params/tutorial001_an_py310.py!}
{!> ../../docs_src/cookie_params/tutorial001_an_py310.py!}
```
////
@@ -75,7 +75,7 @@ Der erste Wert ist der Typ. Sie können `Cookie` die gehabten Extra Validierungs
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
{!> ../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
////
@@ -83,7 +83,7 @@ Der erste Wert ist der Typ. Sie können `Cookie` die gehabten Extra Validierungs
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
{!> ../../docs_src/cookie_params/tutorial001_an.py!}
```
////
@@ -97,7 +97,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
{!> ../../docs_src/cookie_params/tutorial001_py310.py!}
```
////
@@ -111,7 +111,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/cookie_params/tutorial001.py!}
{!> ../../docs_src/cookie_params/tutorial001.py!}
```
////

View File

@@ -9,7 +9,7 @@ Im vorherigen Beispiel haben wir ein `dict` von unserer Abhängigkeit („Depend
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py310.py!}
```
////
@@ -17,7 +17,7 @@ Im vorherigen Beispiel haben wir ein `dict` von unserer Abhängigkeit („Depend
//// tab | Python 3.9+
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Im vorherigen Beispiel haben wir ein `dict` von unserer Abhängigkeit („Depend
//// tab | Python 3.8+
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
{!> ../../docs_src/dependencies/tutorial001_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_py310.py!}
```
////
@@ -53,7 +53,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial001.py!}
{!> ../../docs_src/dependencies/tutorial001.py!}
```
////
@@ -122,7 +122,7 @@ Dann können wir das „Dependable“ `common_parameters` der Abhängigkeit von
//// tab | Python 3.10+
```Python hl_lines="11-15"
{!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial002_an_py310.py!}
```
////
@@ -130,7 +130,7 @@ Dann können wir das „Dependable“ `common_parameters` der Abhängigkeit von
//// tab | Python 3.9+
```Python hl_lines="11-15"
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial002_an_py39.py!}
```
////
@@ -138,7 +138,7 @@ Dann können wir das „Dependable“ `common_parameters` der Abhängigkeit von
//// tab | Python 3.8+
```Python hl_lines="12-16"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
{!> ../../docs_src/dependencies/tutorial002_an.py!}
```
////
@@ -152,7 +152,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9-13"
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
{!> ../../docs_src/dependencies/tutorial002_py310.py!}
```
////
@@ -166,7 +166,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11-15"
{!> ../../../docs_src/dependencies/tutorial002.py!}
{!> ../../docs_src/dependencies/tutorial002.py!}
```
////
@@ -176,7 +176,7 @@ Achten Sie auf die Methode `__init__`, die zum Erstellen der Instanz der Klasse
//// tab | Python 3.10+
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial002_an_py310.py!}
```
////
@@ -184,7 +184,7 @@ Achten Sie auf die Methode `__init__`, die zum Erstellen der Instanz der Klasse
//// tab | Python 3.9+
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial002_an_py39.py!}
```
////
@@ -192,7 +192,7 @@ Achten Sie auf die Methode `__init__`, die zum Erstellen der Instanz der Klasse
//// tab | Python 3.8+
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
{!> ../../docs_src/dependencies/tutorial002_an.py!}
```
////
@@ -206,7 +206,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
{!> ../../docs_src/dependencies/tutorial002_py310.py!}
```
////
@@ -220,7 +220,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial002.py!}
{!> ../../docs_src/dependencies/tutorial002.py!}
```
////
@@ -230,7 +230,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.10+
```Python hl_lines="8"
{!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py310.py!}
```
////
@@ -238,7 +238,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py39.py!}
```
////
@@ -246,7 +246,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
{!> ../../docs_src/dependencies/tutorial001_an.py!}
```
////
@@ -260,7 +260,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_py310.py!}
```
////
@@ -274,7 +274,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/dependencies/tutorial001.py!}
{!> ../../docs_src/dependencies/tutorial001.py!}
```
////
@@ -296,7 +296,7 @@ Jetzt können Sie Ihre Abhängigkeit mithilfe dieser Klasse deklarieren.
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial002_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial002_an_py310.py!}
```
////
@@ -304,7 +304,7 @@ Jetzt können Sie Ihre Abhängigkeit mithilfe dieser Klasse deklarieren.
//// tab | Python 3.9+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial002_an_py39.py!}
```
////
@@ -312,7 +312,7 @@ Jetzt können Sie Ihre Abhängigkeit mithilfe dieser Klasse deklarieren.
//// tab | Python 3.8+
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
{!> ../../docs_src/dependencies/tutorial002_an.py!}
```
////
@@ -326,7 +326,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
{!> ../../docs_src/dependencies/tutorial002_py310.py!}
```
////
@@ -340,7 +340,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial002.py!}
{!> ../../docs_src/dependencies/tutorial002.py!}
```
////
@@ -440,7 +440,7 @@ commons = Depends(CommonQueryParams)
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial003_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial003_an_py310.py!}
```
////
@@ -448,7 +448,7 @@ commons = Depends(CommonQueryParams)
//// tab | Python 3.9+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial003_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial003_an_py39.py!}
```
////
@@ -456,7 +456,7 @@ commons = Depends(CommonQueryParams)
//// tab | Python 3.8+
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial003_an.py!}
{!> ../../docs_src/dependencies/tutorial003_an.py!}
```
////
@@ -470,7 +470,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial003_py310.py!}
{!> ../../docs_src/dependencies/tutorial003_py310.py!}
```
////
@@ -484,7 +484,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial003.py!}
{!> ../../docs_src/dependencies/tutorial003.py!}
```
////
@@ -578,7 +578,7 @@ Dasselbe Beispiel würde dann so aussehen:
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial004_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial004_an_py310.py!}
```
////
@@ -586,7 +586,7 @@ Dasselbe Beispiel würde dann so aussehen:
//// tab | Python 3.9+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial004_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial004_an_py39.py!}
```
////
@@ -594,7 +594,7 @@ Dasselbe Beispiel würde dann so aussehen:
//// tab | Python 3.8+
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial004_an.py!}
{!> ../../docs_src/dependencies/tutorial004_an.py!}
```
////
@@ -608,7 +608,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial004_py310.py!}
{!> ../../docs_src/dependencies/tutorial004_py310.py!}
```
////
@@ -622,7 +622,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial004.py!}
{!> ../../docs_src/dependencies/tutorial004.py!}
```
////

View File

@@ -17,7 +17,7 @@ Es sollte eine `list`e von `Depends()` sein:
//// tab | Python 3.9+
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial006_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Es sollte eine `list`e von `Depends()` sein:
//// tab | Python 3.8+
```Python hl_lines="18"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
{!> ../../docs_src/dependencies/tutorial006_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial006.py!}
{!> ../../docs_src/dependencies/tutorial006.py!}
```
////
@@ -75,7 +75,7 @@ Sie können Anforderungen für einen Request (wie Header) oder andere Unterabhä
//// tab | Python 3.9+
```Python hl_lines="8 13"
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial006_an_py39.py!}
```
////
@@ -83,7 +83,7 @@ Sie können Anforderungen für einen Request (wie Header) oder andere Unterabhä
//// tab | Python 3.8+
```Python hl_lines="7 12"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
{!> ../../docs_src/dependencies/tutorial006_an.py!}
```
////
@@ -97,7 +97,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6 11"
{!> ../../../docs_src/dependencies/tutorial006.py!}
{!> ../../docs_src/dependencies/tutorial006.py!}
```
////
@@ -109,7 +109,7 @@ Die Abhängigkeiten können Exceptions `raise`n, genau wie normale Abhängigkeit
//// tab | Python 3.9+
```Python hl_lines="10 15"
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial006_an_py39.py!}
```
////
@@ -117,7 +117,7 @@ Die Abhängigkeiten können Exceptions `raise`n, genau wie normale Abhängigkeit
//// tab | Python 3.8+
```Python hl_lines="9 14"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
{!> ../../docs_src/dependencies/tutorial006_an.py!}
```
////
@@ -131,7 +131,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8 13"
{!> ../../../docs_src/dependencies/tutorial006.py!}
{!> ../../docs_src/dependencies/tutorial006.py!}
```
////
@@ -145,7 +145,7 @@ Sie können also eine normale Abhängigkeit (die einen Wert zurückgibt), die Si
//// tab | Python 3.9+
```Python hl_lines="11 16"
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial006_an_py39.py!}
```
////
@@ -153,7 +153,7 @@ Sie können also eine normale Abhängigkeit (die einen Wert zurückgibt), die Si
//// tab | Python 3.8+
```Python hl_lines="10 15"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
{!> ../../docs_src/dependencies/tutorial006_an.py!}
```
////
@@ -167,7 +167,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9 14"
{!> ../../../docs_src/dependencies/tutorial006.py!}
{!> ../../docs_src/dependencies/tutorial006.py!}
```
////

View File

@@ -30,19 +30,19 @@ Sie könnten damit beispielsweise eine Datenbanksession erstellen und diese nach
Nur der Code vor und einschließlich der `yield`-Anweisung wird ausgeführt, bevor eine Response erzeugt wird:
```Python hl_lines="2-4"
{!../../../docs_src/dependencies/tutorial007.py!}
{!../../docs_src/dependencies/tutorial007.py!}
```
Der ge`yield`ete Wert ist das, was in *Pfadoperationen* und andere Abhängigkeiten eingefügt wird:
```Python hl_lines="4"
{!../../../docs_src/dependencies/tutorial007.py!}
{!../../docs_src/dependencies/tutorial007.py!}
```
Der auf die `yield`-Anweisung folgende Code wird ausgeführt, nachdem die Response gesendet wurde:
```Python hl_lines="5-6"
{!../../../docs_src/dependencies/tutorial007.py!}
{!../../docs_src/dependencies/tutorial007.py!}
```
/// tip | "Tipp"
@@ -64,7 +64,7 @@ Sie können also mit `except SomeException` diese bestimmte Exception innerhalb
Auf die gleiche Weise können Sie `finally` verwenden, um sicherzustellen, dass die Exit-Schritte ausgeführt werden, unabhängig davon, ob eine Exception geworfen wurde oder nicht.
```Python hl_lines="3 5"
{!../../../docs_src/dependencies/tutorial007.py!}
{!../../docs_src/dependencies/tutorial007.py!}
```
## Unterabhängigkeiten mit `yield`.
@@ -78,7 +78,7 @@ Beispielsweise kann `dependency_c` von `dependency_b` und `dependency_b` von `de
//// tab | Python 3.9+
```Python hl_lines="6 14 22"
{!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial008_an_py39.py!}
```
////
@@ -86,7 +86,7 @@ Beispielsweise kann `dependency_c` von `dependency_b` und `dependency_b` von `de
//// tab | Python 3.8+
```Python hl_lines="5 13 21"
{!> ../../../docs_src/dependencies/tutorial008_an.py!}
{!> ../../docs_src/dependencies/tutorial008_an.py!}
```
////
@@ -100,7 +100,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="4 12 20"
{!> ../../../docs_src/dependencies/tutorial008.py!}
{!> ../../docs_src/dependencies/tutorial008.py!}
```
////
@@ -114,7 +114,7 @@ Und wiederum benötigt `dependency_b` den Wert von `dependency_a` (hier `dep_a`
//// tab | Python 3.9+
```Python hl_lines="18-19 26-27"
{!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial008_an_py39.py!}
```
////
@@ -122,7 +122,7 @@ Und wiederum benötigt `dependency_b` den Wert von `dependency_a` (hier `dep_a`
//// tab | Python 3.8+
```Python hl_lines="17-18 25-26"
{!> ../../../docs_src/dependencies/tutorial008_an.py!}
{!> ../../docs_src/dependencies/tutorial008_an.py!}
```
////
@@ -136,7 +136,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="16-17 24-25"
{!> ../../../docs_src/dependencies/tutorial008.py!}
{!> ../../docs_src/dependencies/tutorial008.py!}
```
////
@@ -174,7 +174,7 @@ Aber es ist für Sie da, wenn Sie es brauchen. 🤓
//// tab | Python 3.9+
```Python hl_lines="18-22 31"
{!> ../../../docs_src/dependencies/tutorial008b_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial008b_an_py39.py!}
```
////
@@ -182,7 +182,7 @@ Aber es ist für Sie da, wenn Sie es brauchen. 🤓
//// tab | Python 3.8+
```Python hl_lines="17-21 30"
{!> ../../../docs_src/dependencies/tutorial008b_an.py!}
{!> ../../docs_src/dependencies/tutorial008b_an.py!}
```
////
@@ -196,7 +196,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="16-20 29"
{!> ../../../docs_src/dependencies/tutorial008b.py!}
{!> ../../docs_src/dependencies/tutorial008b.py!}
```
////
@@ -321,7 +321,7 @@ In Python können Sie Kontextmanager erstellen, indem Sie <a href="https://docs.
Sie können solche auch innerhalb von **FastAPI**-Abhängigkeiten mit `yield` verwenden, indem Sie `with`- oder `async with`-Anweisungen innerhalb der Abhängigkeits-Funktion verwenden:
```Python hl_lines="1-9 13"
{!../../../docs_src/dependencies/tutorial010.py!}
{!../../docs_src/dependencies/tutorial010.py!}
```
/// tip | "Tipp"

View File

@@ -9,7 +9,7 @@ In diesem Fall werden sie auf alle *Pfadoperationen* in der Anwendung angewendet
//// tab | Python 3.9+
```Python hl_lines="16"
{!> ../../../docs_src/dependencies/tutorial012_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial012_an_py39.py!}
```
////
@@ -17,7 +17,7 @@ In diesem Fall werden sie auf alle *Pfadoperationen* in der Anwendung angewendet
//// tab | Python 3.8+
```Python hl_lines="16"
{!> ../../../docs_src/dependencies/tutorial012_an.py!}
{!> ../../docs_src/dependencies/tutorial012_an.py!}
```
////
@@ -31,7 +31,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="15"
{!> ../../../docs_src/dependencies/tutorial012.py!}
{!> ../../docs_src/dependencies/tutorial012.py!}
```
////

View File

@@ -33,7 +33,7 @@ Es handelt sich einfach um eine Funktion, die die gleichen Parameter entgegennim
//// tab | Python 3.10+
```Python hl_lines="8-9"
{!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py310.py!}
```
////
@@ -41,7 +41,7 @@ Es handelt sich einfach um eine Funktion, die die gleichen Parameter entgegennim
//// tab | Python 3.9+
```Python hl_lines="8-11"
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py39.py!}
```
////
@@ -49,7 +49,7 @@ Es handelt sich einfach um eine Funktion, die die gleichen Parameter entgegennim
//// tab | Python 3.8+
```Python hl_lines="9-12"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
{!> ../../docs_src/dependencies/tutorial001_an.py!}
```
////
@@ -63,7 +63,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6-7"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_py310.py!}
```
////
@@ -77,7 +77,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8-11"
{!> ../../../docs_src/dependencies/tutorial001.py!}
{!> ../../docs_src/dependencies/tutorial001.py!}
```
////
@@ -115,7 +115,7 @@ Bitte [aktualisieren Sie FastAPI](../../deployment/versions.md#upgrade-der-fasta
//// tab | Python 3.10+
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py310.py!}
```
////
@@ -123,7 +123,7 @@ Bitte [aktualisieren Sie FastAPI](../../deployment/versions.md#upgrade-der-fasta
//// tab | Python 3.9+
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py39.py!}
```
////
@@ -131,7 +131,7 @@ Bitte [aktualisieren Sie FastAPI](../../deployment/versions.md#upgrade-der-fasta
//// tab | Python 3.8+
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
{!> ../../docs_src/dependencies/tutorial001_an.py!}
```
////
@@ -145,7 +145,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_py310.py!}
```
////
@@ -159,7 +159,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001.py!}
{!> ../../docs_src/dependencies/tutorial001.py!}
```
////
@@ -171,7 +171,7 @@ So wie auch `Body`, `Query`, usw., verwenden Sie `Depends` mit den Parametern Ih
//// tab | Python 3.10+
```Python hl_lines="13 18"
{!> ../../../docs_src/dependencies/tutorial001_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py310.py!}
```
////
@@ -179,7 +179,7 @@ So wie auch `Body`, `Query`, usw., verwenden Sie `Depends` mit den Parametern Ih
//// tab | Python 3.9+
```Python hl_lines="15 20"
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial001_an_py39.py!}
```
////
@@ -187,7 +187,7 @@ So wie auch `Body`, `Query`, usw., verwenden Sie `Depends` mit den Parametern Ih
//// tab | Python 3.8+
```Python hl_lines="16 21"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
{!> ../../docs_src/dependencies/tutorial001_an.py!}
```
////
@@ -201,7 +201,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11 16"
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_py310.py!}
```
////
@@ -215,7 +215,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="15 20"
{!> ../../../docs_src/dependencies/tutorial001.py!}
{!> ../../docs_src/dependencies/tutorial001.py!}
```
////
@@ -278,7 +278,7 @@ Da wir jedoch `Annotated` verwenden, können wir diesen `Annotated`-Wert in eine
//// tab | Python 3.10+
```Python hl_lines="12 16 21"
{!> ../../../docs_src/dependencies/tutorial001_02_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial001_02_an_py310.py!}
```
////
@@ -286,7 +286,7 @@ Da wir jedoch `Annotated` verwenden, können wir diesen `Annotated`-Wert in eine
//// tab | Python 3.9+
```Python hl_lines="14 18 23"
{!> ../../../docs_src/dependencies/tutorial001_02_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial001_02_an_py39.py!}
```
////
@@ -294,7 +294,7 @@ Da wir jedoch `Annotated` verwenden, können wir diesen `Annotated`-Wert in eine
//// tab | Python 3.8+
```Python hl_lines="15 19 24"
{!> ../../../docs_src/dependencies/tutorial001_02_an.py!}
{!> ../../docs_src/dependencies/tutorial001_02_an.py!}
```
////

View File

@@ -13,7 +13,7 @@ Sie könnten eine erste Abhängigkeit („Dependable“) wie folgt erstellen:
//// tab | Python 3.10+
```Python hl_lines="8-9"
{!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial005_an_py310.py!}
```
////
@@ -21,7 +21,7 @@ Sie könnten eine erste Abhängigkeit („Dependable“) wie folgt erstellen:
//// tab | Python 3.9+
```Python hl_lines="8-9"
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial005_an_py39.py!}
```
////
@@ -29,7 +29,7 @@ Sie könnten eine erste Abhängigkeit („Dependable“) wie folgt erstellen:
//// tab | Python 3.8+
```Python hl_lines="9-10"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
{!> ../../docs_src/dependencies/tutorial005_an.py!}
```
////
@@ -43,7 +43,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6-7"
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
{!> ../../docs_src/dependencies/tutorial005_py310.py!}
```
////
@@ -57,7 +57,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8-9"
{!> ../../../docs_src/dependencies/tutorial005.py!}
{!> ../../docs_src/dependencies/tutorial005.py!}
```
////
@@ -73,7 +73,7 @@ Dann können Sie eine weitere Abhängigkeitsfunktion (ein „Dependable“) erst
//// tab | Python 3.10+
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial005_an_py310.py!}
```
////
@@ -81,7 +81,7 @@ Dann können Sie eine weitere Abhängigkeitsfunktion (ein „Dependable“) erst
//// tab | Python 3.9+
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial005_an_py39.py!}
```
////
@@ -89,7 +89,7 @@ Dann können Sie eine weitere Abhängigkeitsfunktion (ein „Dependable“) erst
//// tab | Python 3.8+
```Python hl_lines="14"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
{!> ../../docs_src/dependencies/tutorial005_an.py!}
```
////
@@ -103,7 +103,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
{!> ../../docs_src/dependencies/tutorial005_py310.py!}
```
////
@@ -117,7 +117,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial005.py!}
{!> ../../docs_src/dependencies/tutorial005.py!}
```
////
@@ -136,7 +136,7 @@ Diese Abhängigkeit verwenden wir nun wie folgt:
//// tab | Python 3.10+
```Python hl_lines="23"
{!> ../../../docs_src/dependencies/tutorial005_an_py310.py!}
{!> ../../docs_src/dependencies/tutorial005_an_py310.py!}
```
////
@@ -144,7 +144,7 @@ Diese Abhängigkeit verwenden wir nun wie folgt:
//// tab | Python 3.9+
```Python hl_lines="23"
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
{!> ../../docs_src/dependencies/tutorial005_an_py39.py!}
```
////
@@ -152,7 +152,7 @@ Diese Abhängigkeit verwenden wir nun wie folgt:
//// tab | Python 3.8+
```Python hl_lines="24"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
{!> ../../docs_src/dependencies/tutorial005_an.py!}
```
////
@@ -166,7 +166,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19"
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
{!> ../../docs_src/dependencies/tutorial005_py310.py!}
```
////
@@ -180,7 +180,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="22"
{!> ../../../docs_src/dependencies/tutorial005.py!}
{!> ../../docs_src/dependencies/tutorial005.py!}
```
////

View File

@@ -23,7 +23,7 @@ Es nimmt ein Objekt entgegen, wie etwa ein Pydantic-Modell, und gibt eine JSON-k
//// tab | Python 3.10+
```Python hl_lines="4 21"
{!> ../../../docs_src/encoder/tutorial001_py310.py!}
{!> ../../docs_src/encoder/tutorial001_py310.py!}
```
////
@@ -31,7 +31,7 @@ Es nimmt ein Objekt entgegen, wie etwa ein Pydantic-Modell, und gibt eine JSON-k
//// tab | Python 3.8+
```Python hl_lines="5 22"
{!> ../../../docs_src/encoder/tutorial001.py!}
{!> ../../docs_src/encoder/tutorial001.py!}
```
////

View File

@@ -58,7 +58,7 @@ Hier ist ein Beispiel für eine *Pfadoperation* mit Parametern, die einige der o
//// tab | Python 3.10+
```Python hl_lines="1 3 12-16"
{!> ../../../docs_src/extra_data_types/tutorial001_an_py310.py!}
{!> ../../docs_src/extra_data_types/tutorial001_an_py310.py!}
```
////
@@ -66,7 +66,7 @@ Hier ist ein Beispiel für eine *Pfadoperation* mit Parametern, die einige der o
//// tab | Python 3.9+
```Python hl_lines="1 3 12-16"
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
{!> ../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
////
@@ -74,7 +74,7 @@ Hier ist ein Beispiel für eine *Pfadoperation* mit Parametern, die einige der o
//// tab | Python 3.8+
```Python hl_lines="1 3 13-17"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
{!> ../../docs_src/extra_data_types/tutorial001_an.py!}
```
////
@@ -88,7 +88,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1 2 11-15"
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
{!> ../../docs_src/extra_data_types/tutorial001_py310.py!}
```
////
@@ -102,7 +102,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1 2 12-16"
{!> ../../../docs_src/extra_data_types/tutorial001.py!}
{!> ../../docs_src/extra_data_types/tutorial001.py!}
```
////
@@ -112,7 +112,7 @@ Beachten Sie, dass die Parameter innerhalb der Funktion ihren natürlichen Daten
//// tab | Python 3.10+
```Python hl_lines="18-19"
{!> ../../../docs_src/extra_data_types/tutorial001_an_py310.py!}
{!> ../../docs_src/extra_data_types/tutorial001_an_py310.py!}
```
////
@@ -120,7 +120,7 @@ Beachten Sie, dass die Parameter innerhalb der Funktion ihren natürlichen Daten
//// tab | Python 3.9+
```Python hl_lines="18-19"
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
{!> ../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
////
@@ -128,7 +128,7 @@ Beachten Sie, dass die Parameter innerhalb der Funktion ihren natürlichen Daten
//// tab | Python 3.8+
```Python hl_lines="19-20"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
{!> ../../docs_src/extra_data_types/tutorial001_an.py!}
```
////
@@ -142,7 +142,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17-18"
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
{!> ../../docs_src/extra_data_types/tutorial001_py310.py!}
```
////
@@ -156,7 +156,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="18-19"
{!> ../../../docs_src/extra_data_types/tutorial001.py!}
{!> ../../docs_src/extra_data_types/tutorial001.py!}
```
////

View File

@@ -23,7 +23,7 @@ Hier der generelle Weg, wie die Modelle mit ihren Passwort-Feldern aussehen kön
//// tab | Python 3.10+
```Python hl_lines="7 9 14 20 22 27-28 31-33 38-39"
{!> ../../../docs_src/extra_models/tutorial001_py310.py!}
{!> ../../docs_src/extra_models/tutorial001_py310.py!}
```
////
@@ -31,7 +31,7 @@ Hier der generelle Weg, wie die Modelle mit ihren Passwort-Feldern aussehen kön
//// tab | Python 3.8+
```Python hl_lines="9 11 16 22 24 29-30 33-35 40-41"
{!> ../../../docs_src/extra_models/tutorial001.py!}
{!> ../../docs_src/extra_models/tutorial001.py!}
```
////
@@ -179,7 +179,7 @@ Auf diese Weise beschreiben wir nur noch die Unterschiede zwischen den Modellen
//// tab | Python 3.10+
```Python hl_lines="7 13-14 17-18 21-22"
{!> ../../../docs_src/extra_models/tutorial002_py310.py!}
{!> ../../docs_src/extra_models/tutorial002_py310.py!}
```
////
@@ -187,7 +187,7 @@ Auf diese Weise beschreiben wir nur noch die Unterschiede zwischen den Modellen
//// tab | Python 3.8+
```Python hl_lines="9 15-16 19-20 23-24"
{!> ../../../docs_src/extra_models/tutorial002.py!}
{!> ../../docs_src/extra_models/tutorial002.py!}
```
////
@@ -209,7 +209,7 @@ Listen Sie, wenn Sie eine <a href="https://pydantic-docs.helpmanual.io/usage/typ
//// tab | Python 3.10+
```Python hl_lines="1 14-15 18-20 33"
{!> ../../../docs_src/extra_models/tutorial003_py310.py!}
{!> ../../docs_src/extra_models/tutorial003_py310.py!}
```
////
@@ -217,7 +217,7 @@ Listen Sie, wenn Sie eine <a href="https://pydantic-docs.helpmanual.io/usage/typ
//// tab | Python 3.8+
```Python hl_lines="1 14-15 18-20 33"
{!> ../../../docs_src/extra_models/tutorial003.py!}
{!> ../../docs_src/extra_models/tutorial003.py!}
```
////
@@ -245,7 +245,7 @@ Verwenden Sie dafür Pythons Standard `typing.List` (oder nur `list` in Python 3
//// tab | Python 3.9+
```Python hl_lines="18"
{!> ../../../docs_src/extra_models/tutorial004_py39.py!}
{!> ../../docs_src/extra_models/tutorial004_py39.py!}
```
////
@@ -253,7 +253,7 @@ Verwenden Sie dafür Pythons Standard `typing.List` (oder nur `list` in Python 3
//// tab | Python 3.8+
```Python hl_lines="1 20"
{!> ../../../docs_src/extra_models/tutorial004.py!}
{!> ../../docs_src/extra_models/tutorial004.py!}
```
////
@@ -269,7 +269,7 @@ In diesem Fall können Sie `typing.Dict` verwenden (oder nur `dict` in Python 3.
//// tab | Python 3.9+
```Python hl_lines="6"
{!> ../../../docs_src/extra_models/tutorial005_py39.py!}
{!> ../../docs_src/extra_models/tutorial005_py39.py!}
```
////
@@ -277,7 +277,7 @@ In diesem Fall können Sie `typing.Dict` verwenden (oder nur `dict` in Python 3.
//// tab | Python 3.8+
```Python hl_lines="1 8"
{!> ../../../docs_src/extra_models/tutorial005.py!}
{!> ../../docs_src/extra_models/tutorial005.py!}
```
////

View File

@@ -3,7 +3,7 @@
Die einfachste FastAPI-Datei könnte wie folgt aussehen:
```Python
{!../../../docs_src/first_steps/tutorial001.py!}
{!../../docs_src/first_steps/tutorial001.py!}
```
Kopieren Sie dies in eine Datei `main.py`.
@@ -134,7 +134,7 @@ Ebenfalls können Sie es verwenden, um automatisch Code für Clients zu generier
### Schritt 1: Importieren von `FastAPI`
```Python hl_lines="1"
{!../../../docs_src/first_steps/tutorial001.py!}
{!../../docs_src/first_steps/tutorial001.py!}
```
`FastAPI` ist eine Python-Klasse, die die gesamte Funktionalität für Ihre API bereitstellt.
@@ -150,7 +150,7 @@ Sie können alle <a href="https://www.starlette.io/" class="external-link" targe
### Schritt 2: Erzeugen einer `FastAPI`-„Instanz“
```Python hl_lines="3"
{!../../../docs_src/first_steps/tutorial001.py!}
{!../../docs_src/first_steps/tutorial001.py!}
```
In diesem Beispiel ist die Variable `app` eine „Instanz“ der Klasse `FastAPI`.
@@ -172,7 +172,7 @@ $ uvicorn main:app --reload
Wenn Sie Ihre Anwendung wie folgt erstellen:
```Python hl_lines="3"
{!../../../docs_src/first_steps/tutorial002.py!}
{!../../docs_src/first_steps/tutorial002.py!}
```
Und in eine Datei `main.py` einfügen, dann würden Sie `uvicorn` wie folgt aufrufen:
@@ -251,7 +251,7 @@ Wir werden sie auch „**Operationen**“ nennen.
#### Definieren eines *Pfadoperation-Dekorators*
```Python hl_lines="6"
{!../../../docs_src/first_steps/tutorial001.py!}
{!../../docs_src/first_steps/tutorial001.py!}
```
Das `@app.get("/")` sagt **FastAPI**, dass die Funktion direkt darunter für die Bearbeitung von Anfragen zuständig ist, die an:
@@ -307,7 +307,7 @@ Das ist unsere „**Pfadoperation-Funktion**“:
* **Funktion**: ist die Funktion direkt unter dem „Dekorator“ (unter `@app.get("/")`).
```Python hl_lines="7"
{!../../../docs_src/first_steps/tutorial001.py!}
{!../../docs_src/first_steps/tutorial001.py!}
```
Dies ist eine Python-Funktion.
@@ -321,7 +321,7 @@ In diesem Fall handelt es sich um eine `async`-Funktion.
Sie könnten sie auch als normale Funktion anstelle von `async def` definieren:
```Python hl_lines="7"
{!../../../docs_src/first_steps/tutorial003.py!}
{!../../docs_src/first_steps/tutorial003.py!}
```
/// note | "Hinweis"
@@ -333,7 +333,7 @@ Wenn Sie den Unterschied nicht kennen, lesen Sie [Async: *„In Eile?“*](../as
### Schritt 5: den Inhalt zurückgeben
```Python hl_lines="8"
{!../../../docs_src/first_steps/tutorial001.py!}
{!../../docs_src/first_steps/tutorial001.py!}
```
Sie können ein `dict`, eine `list`, einzelne Werte wie `str`, `int`, usw. zurückgeben.

View File

@@ -26,7 +26,7 @@ Um HTTP-Responses mit Fehlern zum Client zurückzugeben, verwenden Sie `HTTPExce
### `HTTPException` importieren
```Python hl_lines="1"
{!../../../docs_src/handling_errors/tutorial001.py!}
{!../../docs_src/handling_errors/tutorial001.py!}
```
### Eine `HTTPException` in Ihrem Code auslösen
@@ -42,7 +42,7 @@ Der Vorteil, eine Exception auszulösen (`raise`), statt sie zurückzugeben (`re
Im folgenden Beispiel lösen wir, wenn der Client eine ID anfragt, die nicht existiert, eine Exception mit dem Statuscode `404` aus.
```Python hl_lines="11"
{!../../../docs_src/handling_errors/tutorial001.py!}
{!../../docs_src/handling_errors/tutorial001.py!}
```
### Die resultierende Response
@@ -82,7 +82,7 @@ Sie müssen das wahrscheinlich nicht direkt in ihrem Code verwenden.
Aber falls es in einem fortgeschrittenen Szenario notwendig ist, können Sie benutzerdefinierte Header wie folgt hinzufügen:
```Python hl_lines="14"
{!../../../docs_src/handling_errors/tutorial002.py!}
{!../../docs_src/handling_errors/tutorial002.py!}
```
## Benutzerdefinierte Exceptionhandler definieren
@@ -96,7 +96,7 @@ Und Sie möchten diese Exception global mit FastAPI handhaben.
Sie könnten einen benutzerdefinierten Exceptionhandler mittels `@app.exception_handler()` hinzufügen:
```Python hl_lines="5-7 13-18 24"
{!../../../docs_src/handling_errors/tutorial003.py!}
{!../../docs_src/handling_errors/tutorial003.py!}
```
Wenn Sie nun `/unicorns/yolo` anfragen, `raise`d die *Pfadoperation* eine `UnicornException`.
@@ -136,7 +136,7 @@ Um diesen zu überschreiben, importieren Sie den `RequestValidationError` und ve
Der Exceptionhandler wird einen `Request` und die Exception entgegennehmen.
```Python hl_lines="2 14-16"
{!../../../docs_src/handling_errors/tutorial004.py!}
{!../../docs_src/handling_errors/tutorial004.py!}
```
Wenn Sie nun `/items/foo` besuchen, erhalten Sie statt des Default-JSON-Errors:
@@ -189,7 +189,7 @@ Genauso können Sie den `HTTPException`-Handler überschreiben.
Zum Beispiel könnten Sie eine Klartext-Response statt JSON für diese Fehler zurückgeben wollen:
```Python hl_lines="3-4 9-11 22"
{!../../../docs_src/handling_errors/tutorial004.py!}
{!../../docs_src/handling_errors/tutorial004.py!}
```
/// note | "Technische Details"
@@ -207,7 +207,7 @@ Der `RequestValidationError` enthält den empfangenen `body` mit den ungültigen
Sie könnten diesen verwenden, während Sie Ihre Anwendung entwickeln, um den Body zu loggen und zu debuggen, ihn zum Benutzer zurückzugeben, usw.
```Python hl_lines="14"
{!../../../docs_src/handling_errors/tutorial005.py!}
{!../../docs_src/handling_errors/tutorial005.py!}
```
Jetzt versuchen Sie, einen ungültigen Artikel zu senden:
@@ -265,7 +265,7 @@ from starlette.exceptions import HTTPException as StarletteHTTPException
Wenn Sie die Exception zusammen mit denselben Default-Exceptionhandlern von **FastAPI** verwenden möchten, können Sie die Default-Exceptionhandler von `fastapi.Exception_handlers` importieren und wiederverwenden:
```Python hl_lines="2-5 15 21"
{!../../../docs_src/handling_errors/tutorial006.py!}
{!../../docs_src/handling_errors/tutorial006.py!}
```
In diesem Beispiel `print`en Sie nur den Fehler mit einer sehr ausdrucksstarken Nachricht, aber Sie sehen, worauf wir hinauswollen. Sie können mit der Exception etwas machen und dann einfach die Default-Exceptionhandler wiederverwenden.

View File

@@ -9,7 +9,7 @@ Importieren Sie zuerst `Header`:
//// tab | Python 3.10+
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001_an_py310.py!}
{!> ../../docs_src/header_params/tutorial001_an_py310.py!}
```
////
@@ -17,7 +17,7 @@ Importieren Sie zuerst `Header`:
//// tab | Python 3.9+
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
{!> ../../docs_src/header_params/tutorial001_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Importieren Sie zuerst `Header`:
//// tab | Python 3.8+
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
{!> ../../docs_src/header_params/tutorial001_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
{!> ../../docs_src/header_params/tutorial001_py310.py!}
```
////
@@ -53,7 +53,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001.py!}
{!> ../../docs_src/header_params/tutorial001.py!}
```
////
@@ -67,7 +67,7 @@ Der erste Wert ist der Typ. Sie können `Header` die gehabten Extra Validierungs
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial001_an_py310.py!}
{!> ../../docs_src/header_params/tutorial001_an_py310.py!}
```
////
@@ -75,7 +75,7 @@ Der erste Wert ist der Typ. Sie können `Header` die gehabten Extra Validierungs
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
{!> ../../docs_src/header_params/tutorial001_an_py39.py!}
```
////
@@ -83,7 +83,7 @@ Der erste Wert ist der Typ. Sie können `Header` die gehabten Extra Validierungs
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
{!> ../../docs_src/header_params/tutorial001_an.py!}
```
////
@@ -97,7 +97,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
{!> ../../docs_src/header_params/tutorial001_py310.py!}
```
////
@@ -111,7 +111,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial001.py!}
{!> ../../docs_src/header_params/tutorial001.py!}
```
////
@@ -149,7 +149,7 @@ Wenn Sie aus irgendeinem Grund das automatische Konvertieren von Unterstrichen z
//// tab | Python 3.10+
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial002_an_py310.py!}
{!> ../../docs_src/header_params/tutorial002_an_py310.py!}
```
////
@@ -157,7 +157,7 @@ Wenn Sie aus irgendeinem Grund das automatische Konvertieren von Unterstrichen z
//// tab | Python 3.9+
```Python hl_lines="11"
{!> ../../../docs_src/header_params/tutorial002_an_py39.py!}
{!> ../../docs_src/header_params/tutorial002_an_py39.py!}
```
////
@@ -165,7 +165,7 @@ Wenn Sie aus irgendeinem Grund das automatische Konvertieren von Unterstrichen z
//// tab | Python 3.8+
```Python hl_lines="12"
{!> ../../../docs_src/header_params/tutorial002_an.py!}
{!> ../../docs_src/header_params/tutorial002_an.py!}
```
////
@@ -179,7 +179,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8"
{!> ../../../docs_src/header_params/tutorial002_py310.py!}
{!> ../../docs_src/header_params/tutorial002_py310.py!}
```
////
@@ -193,7 +193,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial002.py!}
{!> ../../docs_src/header_params/tutorial002.py!}
```
////
@@ -217,7 +217,7 @@ Um zum Beispiel einen Header `X-Token` zu deklarieren, der mehrmals vorkommen ka
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial003_an_py310.py!}
{!> ../../docs_src/header_params/tutorial003_an_py310.py!}
```
////
@@ -225,7 +225,7 @@ Um zum Beispiel einen Header `X-Token` zu deklarieren, der mehrmals vorkommen ka
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial003_an_py39.py!}
{!> ../../docs_src/header_params/tutorial003_an_py39.py!}
```
////
@@ -233,7 +233,7 @@ Um zum Beispiel einen Header `X-Token` zu deklarieren, der mehrmals vorkommen ka
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial003_an.py!}
{!> ../../docs_src/header_params/tutorial003_an.py!}
```
////
@@ -247,7 +247,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/header_params/tutorial003_py310.py!}
{!> ../../docs_src/header_params/tutorial003_py310.py!}
```
////
@@ -261,7 +261,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial003_py39.py!}
{!> ../../docs_src/header_params/tutorial003_py39.py!}
```
////
@@ -275,7 +275,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/header_params/tutorial003.py!}
{!> ../../docs_src/header_params/tutorial003.py!}
```
////

View File

@@ -19,7 +19,7 @@ Sie können die folgenden Felder festlegen, welche in der OpenAPI-Spezifikation
Sie können diese wie folgt setzen:
```Python hl_lines="3-16 19-32"
{!../../../docs_src/metadata/tutorial001.py!}
{!../../docs_src/metadata/tutorial001.py!}
```
/// tip | "Tipp"
@@ -39,7 +39,7 @@ Seit OpenAPI 3.1.0 und FastAPI 0.99.0 können Sie die `license_info` auch mit ei
Zum Beispiel:
```Python hl_lines="31"
{!../../../docs_src/metadata/tutorial001_1.py!}
{!../../docs_src/metadata/tutorial001_1.py!}
```
## Metadaten für Tags
@@ -63,7 +63,7 @@ Versuchen wir das an einem Beispiel mit Tags für `users` und `items`.
Erstellen Sie Metadaten für Ihre Tags und übergeben Sie sie an den Parameter `openapi_tags`:
```Python hl_lines="3-16 18"
{!../../../docs_src/metadata/tutorial004.py!}
{!../../docs_src/metadata/tutorial004.py!}
```
Beachten Sie, dass Sie Markdown in den Beschreibungen verwenden können. Beispielsweise wird „login“ in Fettschrift (**login**) und „fancy“ in Kursivschrift (_fancy_) angezeigt.
@@ -79,7 +79,7 @@ Sie müssen nicht für alle von Ihnen verwendeten Tags Metadaten hinzufügen.
Verwenden Sie den Parameter `tags` mit Ihren *Pfadoperationen* (und `APIRouter`n), um diese verschiedenen Tags zuzuweisen:
```Python hl_lines="21 26"
{!../../../docs_src/metadata/tutorial004.py!}
{!../../docs_src/metadata/tutorial004.py!}
```
/// info
@@ -109,7 +109,7 @@ Sie können das aber mit dem Parameter `openapi_url` konfigurieren.
Um beispielsweise festzulegen, dass es unter `/api/v1/openapi.json` bereitgestellt wird:
```Python hl_lines="3"
{!../../../docs_src/metadata/tutorial002.py!}
{!../../docs_src/metadata/tutorial002.py!}
```
Wenn Sie das OpenAPI-Schema vollständig deaktivieren möchten, können Sie `openapi_url=None` festlegen, wodurch auch die Dokumentationsbenutzeroberflächen deaktiviert werden, die es verwenden.
@@ -128,5 +128,5 @@ Sie können die beiden enthaltenen Dokumentationsbenutzeroberflächen konfigurie
Um beispielsweise Swagger UI so einzustellen, dass sie unter `/documentation` bereitgestellt wird, und ReDoc zu deaktivieren:
```Python hl_lines="3"
{!../../../docs_src/metadata/tutorial003.py!}
{!../../docs_src/metadata/tutorial003.py!}
```

View File

@@ -32,7 +32,7 @@ Die Middleware-Funktion erhält:
* Sie können die `response` dann weiter modifizieren, bevor Sie sie zurückgeben.
```Python hl_lines="8-9 11 14"
{!../../../docs_src/middleware/tutorial001.py!}
{!../../docs_src/middleware/tutorial001.py!}
```
/// tip | "Tipp"
@@ -60,7 +60,7 @@ Und auch nachdem die `response` generiert wurde, bevor sie zurückgegeben wird.
Sie könnten beispielsweise einen benutzerdefinierten Header `X-Process-Time` hinzufügen, der die Zeit in Sekunden enthält, die benötigt wurde, um den Request zu verarbeiten und eine Response zu generieren:
```Python hl_lines="10 12-13"
{!../../../docs_src/middleware/tutorial001.py!}
{!../../docs_src/middleware/tutorial001.py!}
```
## Andere Middlewares

View File

@@ -19,7 +19,7 @@ Aber falls Sie sich nicht mehr erinnern, wofür jede Nummer steht, können Sie d
//// tab | Python 3.10+
```Python hl_lines="1 15"
{!> ../../../docs_src/path_operation_configuration/tutorial001_py310.py!}
{!> ../../docs_src/path_operation_configuration/tutorial001_py310.py!}
```
////
@@ -27,7 +27,7 @@ Aber falls Sie sich nicht mehr erinnern, wofür jede Nummer steht, können Sie d
//// tab | Python 3.9+
```Python hl_lines="3 17"
{!> ../../../docs_src/path_operation_configuration/tutorial001_py39.py!}
{!> ../../docs_src/path_operation_configuration/tutorial001_py39.py!}
```
////
@@ -35,7 +35,7 @@ Aber falls Sie sich nicht mehr erinnern, wofür jede Nummer steht, können Sie d
//// tab | Python 3.8+
```Python hl_lines="3 17"
{!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
{!> ../../docs_src/path_operation_configuration/tutorial001.py!}
```
////
@@ -57,7 +57,7 @@ Sie können Ihrer *Pfadoperation* Tags hinzufügen, mittels des Parameters `tags
//// tab | Python 3.10+
```Python hl_lines="15 20 25"
{!> ../../../docs_src/path_operation_configuration/tutorial002_py310.py!}
{!> ../../docs_src/path_operation_configuration/tutorial002_py310.py!}
```
////
@@ -65,7 +65,7 @@ Sie können Ihrer *Pfadoperation* Tags hinzufügen, mittels des Parameters `tags
//// tab | Python 3.9+
```Python hl_lines="17 22 27"
{!> ../../../docs_src/path_operation_configuration/tutorial002_py39.py!}
{!> ../../docs_src/path_operation_configuration/tutorial002_py39.py!}
```
////
@@ -73,7 +73,7 @@ Sie können Ihrer *Pfadoperation* Tags hinzufügen, mittels des Parameters `tags
//// tab | Python 3.8+
```Python hl_lines="17 22 27"
{!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
{!> ../../docs_src/path_operation_configuration/tutorial002.py!}
```
////
@@ -91,7 +91,7 @@ In diesem Fall macht es Sinn, die Tags in einem `Enum` zu speichern.
**FastAPI** unterstützt diese genauso wie einfache Strings:
```Python hl_lines="1 8-10 13 18"
{!../../../docs_src/path_operation_configuration/tutorial002b.py!}
{!../../docs_src/path_operation_configuration/tutorial002b.py!}
```
## Zusammenfassung und Beschreibung
@@ -101,7 +101,7 @@ Sie können eine Zusammenfassung (`summary`) und eine Beschreibung (`description
//// tab | Python 3.10+
```Python hl_lines="18-19"
{!> ../../../docs_src/path_operation_configuration/tutorial003_py310.py!}
{!> ../../docs_src/path_operation_configuration/tutorial003_py310.py!}
```
////
@@ -109,7 +109,7 @@ Sie können eine Zusammenfassung (`summary`) und eine Beschreibung (`description
//// tab | Python 3.9+
```Python hl_lines="20-21"
{!> ../../../docs_src/path_operation_configuration/tutorial003_py39.py!}
{!> ../../docs_src/path_operation_configuration/tutorial003_py39.py!}
```
////
@@ -117,7 +117,7 @@ Sie können eine Zusammenfassung (`summary`) und eine Beschreibung (`description
//// tab | Python 3.8+
```Python hl_lines="20-21"
{!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
{!> ../../docs_src/path_operation_configuration/tutorial003.py!}
```
////
@@ -131,7 +131,7 @@ Sie können im Docstring <a href="https://en.wikipedia.org/wiki/Markdown" class=
//// tab | Python 3.10+
```Python hl_lines="17-25"
{!> ../../../docs_src/path_operation_configuration/tutorial004_py310.py!}
{!> ../../docs_src/path_operation_configuration/tutorial004_py310.py!}
```
////
@@ -139,7 +139,7 @@ Sie können im Docstring <a href="https://en.wikipedia.org/wiki/Markdown" class=
//// tab | Python 3.9+
```Python hl_lines="19-27"
{!> ../../../docs_src/path_operation_configuration/tutorial004_py39.py!}
{!> ../../docs_src/path_operation_configuration/tutorial004_py39.py!}
```
////
@@ -147,7 +147,7 @@ Sie können im Docstring <a href="https://en.wikipedia.org/wiki/Markdown" class=
//// tab | Python 3.8+
```Python hl_lines="19-27"
{!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
{!> ../../docs_src/path_operation_configuration/tutorial004.py!}
```
////
@@ -163,7 +163,7 @@ Die Response können Sie mit dem Parameter `response_description` beschreiben:
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/path_operation_configuration/tutorial005_py310.py!}
{!> ../../docs_src/path_operation_configuration/tutorial005_py310.py!}
```
////
@@ -171,7 +171,7 @@ Die Response können Sie mit dem Parameter `response_description` beschreiben:
//// tab | Python 3.9+
```Python hl_lines="21"
{!> ../../../docs_src/path_operation_configuration/tutorial005_py39.py!}
{!> ../../docs_src/path_operation_configuration/tutorial005_py39.py!}
```
////
@@ -179,7 +179,7 @@ Die Response können Sie mit dem Parameter `response_description` beschreiben:
//// tab | Python 3.8+
```Python hl_lines="21"
{!> ../../../docs_src/path_operation_configuration/tutorial005.py!}
{!> ../../docs_src/path_operation_configuration/tutorial005.py!}
```
////
@@ -205,7 +205,7 @@ Daher, wenn Sie keine vergeben, wird **FastAPI** automatisch eine für „Erfolg
Wenn Sie eine *Pfadoperation* als <abbr title="deprecated obsolet, veraltet: Es soll nicht mehr verwendet werden">deprecated</abbr> kennzeichnen möchten, ohne sie zu entfernen, fügen Sie den Parameter `deprecated` hinzu:
```Python hl_lines="16"
{!../../../docs_src/path_operation_configuration/tutorial006.py!}
{!../../docs_src/path_operation_configuration/tutorial006.py!}
```
Sie wird in der interaktiven Dokumentation gut sichtbar als deprecated markiert werden:

View File

@@ -9,7 +9,7 @@ Importieren Sie zuerst `Path` von `fastapi`, und importieren Sie `Annotated`.
//// tab | Python 3.10+
```Python hl_lines="1 3"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
```
////
@@ -17,7 +17,7 @@ Importieren Sie zuerst `Path` von `fastapi`, und importieren Sie `Annotated`.
//// tab | Python 3.9+
```Python hl_lines="1 3"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Importieren Sie zuerst `Path` von `fastapi`, und importieren Sie `Annotated`.
//// tab | Python 3.8+
```Python hl_lines="3-4"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
////
@@ -53,7 +53,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001.py!}
```
////
@@ -77,7 +77,7 @@ Um zum Beispiel einen `title`-Metadaten-Wert für den Pfad-Parameter `item_id` z
//// tab | Python 3.10+
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
```
////
@@ -85,7 +85,7 @@ Um zum Beispiel einen `title`-Metadaten-Wert für den Pfad-Parameter `item_id` z
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
////
@@ -93,7 +93,7 @@ Um zum Beispiel einen `title`-Metadaten-Wert für den Pfad-Parameter `item_id` z
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
```
////
@@ -107,7 +107,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
////
@@ -121,7 +121,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial001.py!}
```
////
@@ -167,7 +167,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/path_params_numeric_validations/tutorial002.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial002.py!}
```
////
@@ -177,7 +177,7 @@ Aber bedenken Sie, dass Sie dieses Problem nicht haben, wenn Sie `Annotated` ver
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
```
////
@@ -185,7 +185,7 @@ Aber bedenken Sie, dass Sie dieses Problem nicht haben, wenn Sie `Annotated` ver
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
```
////
@@ -214,7 +214,7 @@ Wenn Sie eines der folgenden Dinge tun möchten:
Python macht nichts mit diesem `*`, aber es wird wissen, dass alle folgenden Parameter als <abbr title="Keyword-Argument Schlüsselwort-Argument: Das Argument wird anhand seines Namens erkannt, nicht anhand seiner Reihenfolge in der Argumentliste">Keyword-Argumente</abbr> (Schlüssel-Wert-Paare), auch bekannt als <abbr title="Von: K-ey W-ord Arg-uments"><code>kwargs</code></abbr>, verwendet werden. Selbst wenn diese keinen Defaultwert haben.
```Python hl_lines="7"
{!../../../docs_src/path_params_numeric_validations/tutorial003.py!}
{!../../docs_src/path_params_numeric_validations/tutorial003.py!}
```
### Besser mit `Annotated`
@@ -224,7 +224,7 @@ Bedenken Sie, dass Sie, wenn Sie `Annotated` verwenden, dieses Problem nicht hab
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
```
////
@@ -232,7 +232,7 @@ Bedenken Sie, dass Sie, wenn Sie `Annotated` verwenden, dieses Problem nicht hab
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
```
////
@@ -245,7 +245,7 @@ Hier, mit `ge=1`, wird festgelegt, dass `item_id` eine Ganzzahl benötigt, die g
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
```
////
@@ -253,7 +253,7 @@ Hier, mit `ge=1`, wird festgelegt, dass `item_id` eine Ganzzahl benötigt, die g
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
```
////
@@ -267,7 +267,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8"
{!> ../../../docs_src/path_params_numeric_validations/tutorial004.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial004.py!}
```
////
@@ -282,7 +282,7 @@ Das Gleiche trifft zu auf:
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
```
////
@@ -290,7 +290,7 @@ Das Gleiche trifft zu auf:
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
```
////
@@ -304,7 +304,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial005.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial005.py!}
```
////
@@ -322,7 +322,7 @@ Das gleiche gilt für <abbr title="less than kleiner als"><code>lt</code></a
//// tab | Python 3.9+
```Python hl_lines="13"
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
```
////
@@ -330,7 +330,7 @@ Das gleiche gilt für <abbr title="less than kleiner als"><code>lt</code></a
//// tab | Python 3.8+
```Python hl_lines="12"
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
```
////
@@ -344,7 +344,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11"
{!> ../../../docs_src/path_params_numeric_validations/tutorial006.py!}
{!> ../../docs_src/path_params_numeric_validations/tutorial006.py!}
```
////

View File

@@ -3,7 +3,7 @@
Sie können Pfad-„Parameter“ oder -„Variablen“ mit der gleichen Syntax deklarieren, welche in Python-<abbr title="Format-String Formatierter String: Der String enthält Variablen, die mit geschweiften Klammern umschlossen sind. Solche Stellen werden durch den Wert der Variable ersetzt">Format-Strings</abbr> verwendet wird:
```Python hl_lines="6-7"
{!../../../docs_src/path_params/tutorial001.py!}
{!../../docs_src/path_params/tutorial001.py!}
```
Der Wert des Pfad-Parameters `item_id` wird Ihrer Funktion als das Argument `item_id` übergeben.
@@ -19,7 +19,7 @@ Wenn Sie dieses Beispiel ausführen und auf <a href="http://127.0.0.1:8000/items
Sie können den Typ eines Pfad-Parameters in der Argumentliste der Funktion deklarieren, mit Standard-Python-Typannotationen:
```Python hl_lines="7"
{!../../../docs_src/path_params/tutorial002.py!}
{!../../docs_src/path_params/tutorial002.py!}
```
In diesem Fall wird `item_id` als `int` deklariert, also als Ganzzahl.
@@ -124,7 +124,7 @@ Und Sie haben auch einen Pfad `/users/{user_id}`, um Daten über einen spezifisc
Weil *Pfadoperationen* in ihrer Reihenfolge ausgewertet werden, müssen Sie sicherstellen, dass der Pfad `/users/me` vor `/users/{user_id}` deklariert wurde:
```Python hl_lines="6 11"
{!../../../docs_src/path_params/tutorial003.py!}
{!../../docs_src/path_params/tutorial003.py!}
```
Ansonsten würde der Pfad für `/users/{user_id}` auch `/users/me` auswerten, und annehmen, dass ein Parameter `user_id` mit dem Wert `"me"` übergeben wurde.
@@ -132,7 +132,7 @@ Ansonsten würde der Pfad für `/users/{user_id}` auch `/users/me` auswerten, un
Sie können eine Pfadoperation auch nicht erneut definieren:
```Python hl_lines="6 11"
{!../../../docs_src/path_params/tutorial003b.py!}
{!../../docs_src/path_params/tutorial003b.py!}
```
Die erste Definition wird immer verwendet werden, da ihr Pfad zuerst übereinstimmt.
@@ -150,7 +150,7 @@ Indem Sie von `str` erben, weiß die API Dokumentation, dass die Werte des Enums
Erstellen Sie dann Klassen-Attribute mit festgelegten Werten, welches die erlaubten Werte sein werden:
```Python hl_lines="1 6-9"
{!../../../docs_src/path_params/tutorial005.py!}
{!../../docs_src/path_params/tutorial005.py!}
```
/// info
@@ -170,7 +170,7 @@ Falls Sie sich fragen, was „AlexNet“, „ResNet“ und „LeNet“ ist, das
Dann erstellen Sie einen *Pfad-Parameter*, der als Typ die gerade erstellte Enum-Klasse hat (`ModelName`):
```Python hl_lines="16"
{!../../../docs_src/path_params/tutorial005.py!}
{!../../docs_src/path_params/tutorial005.py!}
```
### Testen Sie es in der API-Dokumentation
@@ -188,7 +188,7 @@ Der *Pfad-Parameter* wird ein *<abbr title="Member Mitglied: Einer der mögl
Sie können ihn mit einem Member Ihres Enums `ModelName` vergleichen:
```Python hl_lines="17"
{!../../../docs_src/path_params/tutorial005.py!}
{!../../docs_src/path_params/tutorial005.py!}
```
#### *Enum-Wert* erhalten
@@ -196,7 +196,7 @@ Sie können ihn mit einem Member Ihres Enums `ModelName` vergleichen:
Den tatsächlichen Wert (in diesem Fall ein `str`) erhalten Sie via `model_name.value`, oder generell, `ihr_enum_member.value`:
```Python hl_lines="20"
{!../../../docs_src/path_params/tutorial005.py!}
{!../../docs_src/path_params/tutorial005.py!}
```
/// tip | "Tipp"
@@ -212,7 +212,7 @@ Sie können *Enum-Member* in ihrer *Pfadoperation* zurückgeben, sogar verschach
Diese werden zu ihren entsprechenden Werten konvertiert (in diesem Fall Strings), bevor sie zum Client übertragen werden:
```Python hl_lines="18 21 23"
{!../../../docs_src/path_params/tutorial005.py!}
{!../../docs_src/path_params/tutorial005.py!}
```
In Ihrem Client erhalten Sie eine JSON-Response, wie etwa:
@@ -253,7 +253,7 @@ In diesem Fall ist der Name des Parameters `file_path`. Der letzte Teil, `:path`
Sie verwenden das also wie folgt:
```Python hl_lines="6"
{!../../../docs_src/path_params/tutorial004.py!}
{!../../docs_src/path_params/tutorial004.py!}
```
/// tip | "Tipp"

View File

@@ -7,7 +7,7 @@ Nehmen wir als Beispiel die folgende Anwendung:
//// tab | Python 3.10+
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial001_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial001_py310.py!}
```
////
@@ -15,7 +15,7 @@ Nehmen wir als Beispiel die folgende Anwendung:
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial001.py!}
{!> ../../docs_src/query_params_str_validations/tutorial001.py!}
```
////
@@ -46,7 +46,7 @@ Importieren Sie zuerst:
In Python 3.9 oder darüber, ist `Annotated` Teil der Standardbibliothek, also können Sie es von `typing` importieren.
```Python hl_lines="1 3"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
////
@@ -58,7 +58,7 @@ In Versionen unter Python 3.9 importieren Sie `Annotated` von `typing_extensions
Es wird bereits mit FastAPI installiert sein.
```Python hl_lines="3-4"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial002_an.py!}
```
////
@@ -126,7 +126,7 @@ Jetzt, da wir `Annotated` für unsere Metadaten deklariert haben, fügen Sie `Qu
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
////
@@ -134,7 +134,7 @@ Jetzt, da wir `Annotated` für unsere Metadaten deklariert haben, fügen Sie `Qu
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial002_an.py!}
```
////
@@ -164,7 +164,7 @@ So würden Sie `Query()` als Defaultwert Ihres Funktionsparameters verwenden, de
//// tab | Python 3.10+
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial002_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial002_py310.py!}
```
////
@@ -172,7 +172,7 @@ So würden Sie `Query()` als Defaultwert Ihres Funktionsparameters verwenden, de
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial002.py!}
{!> ../../docs_src/query_params_str_validations/tutorial002.py!}
```
////
@@ -278,7 +278,7 @@ Sie können auch einen Parameter `min_length` hinzufügen:
//// tab | Python 3.10+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial003_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial003_an_py310.py!}
```
////
@@ -286,7 +286,7 @@ Sie können auch einen Parameter `min_length` hinzufügen:
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial003_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial003_an_py39.py!}
```
////
@@ -294,7 +294,7 @@ Sie können auch einen Parameter `min_length` hinzufügen:
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial003_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial003_an.py!}
```
////
@@ -308,7 +308,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial003_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial003_py310.py!}
```
////
@@ -322,7 +322,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial003.py!}
{!> ../../docs_src/query_params_str_validations/tutorial003.py!}
```
////
@@ -334,7 +334,7 @@ Sie können einen <abbr title="Ein regulärer Ausdruck, auch regex oder regexp g
//// tab | Python 3.10+
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial004_an_py310.py!}
```
////
@@ -342,7 +342,7 @@ Sie können einen <abbr title="Ein regulärer Ausdruck, auch regex oder regexp g
//// tab | Python 3.9+
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial004_an_py39.py!}
```
////
@@ -350,7 +350,7 @@ Sie können einen <abbr title="Ein regulärer Ausdruck, auch regex oder regexp g
//// tab | Python 3.8+
```Python hl_lines="12"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial004_an.py!}
```
////
@@ -364,7 +364,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial004_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial004_py310.py!}
```
////
@@ -378,7 +378,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial004.py!}
{!> ../../docs_src/query_params_str_validations/tutorial004.py!}
```
////
@@ -402,7 +402,7 @@ Sie könnten immer noch Code sehen, der den alten Namen verwendet:
//// tab | Python 3.10+ Pydantic v1
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an_py310_regex.py!}
{!> ../../docs_src/query_params_str_validations/tutorial004_an_py310_regex.py!}
```
////
@@ -418,7 +418,7 @@ Beispielsweise könnten Sie den `q` Query-Parameter so deklarieren, dass er eine
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
```
////
@@ -426,7 +426,7 @@ Beispielsweise könnten Sie den `q` Query-Parameter so deklarieren, dass er eine
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial005_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial005_an.py!}
```
////
@@ -440,7 +440,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial005.py!}
{!> ../../docs_src/query_params_str_validations/tutorial005.py!}
```
////
@@ -488,7 +488,7 @@ Wenn Sie einen Parameter erforderlich machen wollen, während Sie `Query` verwen
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
```
////
@@ -496,7 +496,7 @@ Wenn Sie einen Parameter erforderlich machen wollen, während Sie `Query` verwen
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006_an.py!}
```
////
@@ -510,7 +510,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial006.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006.py!}
```
/// tip | "Tipp"
@@ -530,7 +530,7 @@ Es gibt eine Alternative, die explizit deklariert, dass ein Wert erforderlich is
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
```
////
@@ -538,7 +538,7 @@ Es gibt eine Alternative, die explizit deklariert, dass ein Wert erforderlich is
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006b_an.py!}
```
////
@@ -552,7 +552,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial006b.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006b.py!}
```
////
@@ -576,7 +576,7 @@ Um das zu machen, deklarieren Sie, dass `None` ein gültiger Typ ist, aber verwe
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006c_an_py310.py!}
```
////
@@ -584,7 +584,7 @@ Um das zu machen, deklarieren Sie, dass `None` ein gültiger Typ ist, aber verwe
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006c_an_py39.py!}
```
////
@@ -592,7 +592,7 @@ Um das zu machen, deklarieren Sie, dass `None` ein gültiger Typ ist, aber verwe
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006c_an.py!}
```
////
@@ -606,7 +606,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
```
////
@@ -620,7 +620,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial006c.py!}
{!> ../../docs_src/query_params_str_validations/tutorial006c.py!}
```
////
@@ -646,7 +646,7 @@ Um zum Beispiel einen Query-Parameter `q` zu deklarieren, der mehrere Male in de
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial011_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial011_an_py310.py!}
```
////
@@ -654,7 +654,7 @@ Um zum Beispiel einen Query-Parameter `q` zu deklarieren, der mehrere Male in de
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial011_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial011_an_py39.py!}
```
////
@@ -662,7 +662,7 @@ Um zum Beispiel einen Query-Parameter `q` zu deklarieren, der mehrere Male in de
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial011_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial011_an.py!}
```
////
@@ -676,7 +676,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial011_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial011_py310.py!}
```
////
@@ -690,7 +690,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial011_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial011_py39.py!}
```
////
@@ -704,7 +704,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial011.py!}
{!> ../../docs_src/query_params_str_validations/tutorial011.py!}
```
////
@@ -745,7 +745,7 @@ Und Sie können auch eine Default-`list`e von Werten definieren, wenn keine übe
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
```
////
@@ -753,7 +753,7 @@ Und Sie können auch eine Default-`list`e von Werten definieren, wenn keine übe
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial012_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial012_an.py!}
```
////
@@ -767,7 +767,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial012_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial012_py39.py!}
```
////
@@ -781,7 +781,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial012.py!}
{!> ../../docs_src/query_params_str_validations/tutorial012.py!}
```
////
@@ -810,7 +810,7 @@ Sie können auch `list` direkt verwenden, anstelle von `List[str]` (oder `list[s
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
```
////
@@ -818,7 +818,7 @@ Sie können auch `list` direkt verwenden, anstelle von `List[str]` (oder `list[s
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial013_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial013_an.py!}
```
////
@@ -832,7 +832,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial013.py!}
{!> ../../docs_src/query_params_str_validations/tutorial013.py!}
```
////
@@ -864,7 +864,7 @@ Sie können einen Titel hinzufügen `title`:
//// tab | Python 3.10+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial007_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial007_an_py310.py!}
```
////
@@ -872,7 +872,7 @@ Sie können einen Titel hinzufügen `title`:
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial007_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial007_an_py39.py!}
```
////
@@ -880,7 +880,7 @@ Sie können einen Titel hinzufügen `title`:
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial007_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial007_an.py!}
```
////
@@ -894,7 +894,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial007_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial007_py310.py!}
```
////
@@ -908,7 +908,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial007.py!}
{!> ../../docs_src/query_params_str_validations/tutorial007.py!}
```
////
@@ -918,7 +918,7 @@ Und eine Beschreibung `description`:
//// tab | Python 3.10+
```Python hl_lines="14"
{!> ../../../docs_src/query_params_str_validations/tutorial008_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial008_an_py310.py!}
```
////
@@ -926,7 +926,7 @@ Und eine Beschreibung `description`:
//// tab | Python 3.9+
```Python hl_lines="14"
{!> ../../../docs_src/query_params_str_validations/tutorial008_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial008_an_py39.py!}
```
////
@@ -934,7 +934,7 @@ Und eine Beschreibung `description`:
//// tab | Python 3.8+
```Python hl_lines="15"
{!> ../../../docs_src/query_params_str_validations/tutorial008_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial008_an.py!}
```
////
@@ -948,7 +948,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial008_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial008_py310.py!}
```
////
@@ -962,7 +962,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="13"
{!> ../../../docs_src/query_params_str_validations/tutorial008.py!}
{!> ../../docs_src/query_params_str_validations/tutorial008.py!}
```
////
@@ -988,7 +988,7 @@ Dann können Sie einen `alias` deklarieren, und dieser Alias wird verwendet, um
//// tab | Python 3.10+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial009_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial009_an_py310.py!}
```
////
@@ -996,7 +996,7 @@ Dann können Sie einen `alias` deklarieren, und dieser Alias wird verwendet, um
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial009_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial009_an_py39.py!}
```
////
@@ -1004,7 +1004,7 @@ Dann können Sie einen `alias` deklarieren, und dieser Alias wird verwendet, um
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial009_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial009_an.py!}
```
////
@@ -1018,7 +1018,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/query_params_str_validations/tutorial009_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial009_py310.py!}
```
////
@@ -1032,7 +1032,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial009.py!}
{!> ../../docs_src/query_params_str_validations/tutorial009.py!}
```
////
@@ -1048,7 +1048,7 @@ In diesem Fall fügen Sie den Parameter `deprecated=True` zu `Query` hinzu.
//// tab | Python 3.10+
```Python hl_lines="19"
{!> ../../../docs_src/query_params_str_validations/tutorial010_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial010_an_py310.py!}
```
////
@@ -1056,7 +1056,7 @@ In diesem Fall fügen Sie den Parameter `deprecated=True` zu `Query` hinzu.
//// tab | Python 3.9+
```Python hl_lines="19"
{!> ../../../docs_src/query_params_str_validations/tutorial010_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial010_an_py39.py!}
```
////
@@ -1064,7 +1064,7 @@ In diesem Fall fügen Sie den Parameter `deprecated=True` zu `Query` hinzu.
//// tab | Python 3.8+
```Python hl_lines="20"
{!> ../../../docs_src/query_params_str_validations/tutorial010_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial010_an.py!}
```
////
@@ -1078,7 +1078,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="16"
{!> ../../../docs_src/query_params_str_validations/tutorial010_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial010_py310.py!}
```
////
@@ -1092,7 +1092,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="18"
{!> ../../../docs_src/query_params_str_validations/tutorial010.py!}
{!> ../../docs_src/query_params_str_validations/tutorial010.py!}
```
////
@@ -1108,7 +1108,7 @@ Um einen Query-Parameter vom generierten OpenAPI-Schema auszuschließen (und dah
//// tab | Python 3.10+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial014_an_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial014_an_py310.py!}
```
////
@@ -1116,7 +1116,7 @@ Um einen Query-Parameter vom generierten OpenAPI-Schema auszuschließen (und dah
//// tab | Python 3.9+
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial014_an_py39.py!}
{!> ../../docs_src/query_params_str_validations/tutorial014_an_py39.py!}
```
////
@@ -1124,7 +1124,7 @@ Um einen Query-Parameter vom generierten OpenAPI-Schema auszuschließen (und dah
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial014_an.py!}
{!> ../../docs_src/query_params_str_validations/tutorial014_an.py!}
```
////
@@ -1138,7 +1138,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial014_py310.py!}
{!> ../../docs_src/query_params_str_validations/tutorial014_py310.py!}
```
////
@@ -1152,7 +1152,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial014.py!}
{!> ../../docs_src/query_params_str_validations/tutorial014.py!}
```
////

View File

@@ -3,7 +3,7 @@
Wenn Sie in ihrer Funktion Parameter deklarieren, die nicht Teil der Pfad-Parameter sind, dann werden diese automatisch als „Query“-Parameter interpretiert.
```Python hl_lines="9"
{!../../../docs_src/query_params/tutorial001.py!}
{!../../docs_src/query_params/tutorial001.py!}
```
Query-Parameter (Deutsch: Abfrage-Parameter) sind die Schlüssel-Wert-Paare, die nach dem `?` in einer URL aufgelistet sind, getrennt durch `&`-Zeichen.
@@ -66,7 +66,7 @@ Auf die gleiche Weise können Sie optionale Query-Parameter deklarieren, indem S
//// tab | Python 3.10+
```Python hl_lines="7"
{!> ../../../docs_src/query_params/tutorial002_py310.py!}
{!> ../../docs_src/query_params/tutorial002_py310.py!}
```
////
@@ -74,7 +74,7 @@ Auf die gleiche Weise können Sie optionale Query-Parameter deklarieren, indem S
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial002.py!}
{!> ../../docs_src/query_params/tutorial002.py!}
```
////
@@ -94,7 +94,7 @@ Sie können auch `bool`-Typen deklarieren und sie werden konvertiert:
//// tab | Python 3.10+
```Python hl_lines="7"
{!> ../../../docs_src/query_params/tutorial003_py310.py!}
{!> ../../docs_src/query_params/tutorial003_py310.py!}
```
////
@@ -102,7 +102,7 @@ Sie können auch `bool`-Typen deklarieren und sie werden konvertiert:
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial003.py!}
{!> ../../docs_src/query_params/tutorial003.py!}
```
////
@@ -150,7 +150,7 @@ Parameter werden anhand ihres Namens erkannt:
//// tab | Python 3.10+
```Python hl_lines="6 8"
{!> ../../../docs_src/query_params/tutorial004_py310.py!}
{!> ../../docs_src/query_params/tutorial004_py310.py!}
```
////
@@ -158,7 +158,7 @@ Parameter werden anhand ihres Namens erkannt:
//// tab | Python 3.8+
```Python hl_lines="8 10"
{!> ../../../docs_src/query_params/tutorial004.py!}
{!> ../../docs_src/query_params/tutorial004.py!}
```
////
@@ -172,7 +172,7 @@ Wenn Sie keinen spezifischen Wert haben wollen, sondern der Parameter einfach op
Aber wenn Sie wollen, dass ein Query-Parameter erforderlich ist, vergeben Sie einfach keinen Defaultwert:
```Python hl_lines="6-7"
{!../../../docs_src/query_params/tutorial005.py!}
{!../../docs_src/query_params/tutorial005.py!}
```
Hier ist `needy` ein erforderlicher Query-Parameter vom Typ `str`.
@@ -222,7 +222,7 @@ Und natürlich können Sie einige Parameter als erforderlich, einige mit Default
//// tab | Python 3.10+
```Python hl_lines="8"
{!> ../../../docs_src/query_params/tutorial006_py310.py!}
{!> ../../docs_src/query_params/tutorial006_py310.py!}
```
////
@@ -230,7 +230,7 @@ Und natürlich können Sie einige Parameter als erforderlich, einige mit Default
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/query_params/tutorial006.py!}
{!> ../../docs_src/query_params/tutorial006.py!}
```
////

View File

@@ -19,7 +19,7 @@ Importieren Sie `File` und `UploadFile` von `fastapi`:
//// tab | Python 3.9+
```Python hl_lines="3"
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
{!> ../../docs_src/request_files/tutorial001_an_py39.py!}
```
////
@@ -27,7 +27,7 @@ Importieren Sie `File` und `UploadFile` von `fastapi`:
//// tab | Python 3.8+
```Python hl_lines="1"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
{!> ../../docs_src/request_files/tutorial001_an.py!}
```
////
@@ -41,7 +41,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/request_files/tutorial001.py!}
{!> ../../docs_src/request_files/tutorial001.py!}
```
////
@@ -53,7 +53,7 @@ Erstellen Sie Datei-Parameter, so wie Sie es auch mit `Body` und `Form` machen w
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
{!> ../../docs_src/request_files/tutorial001_an_py39.py!}
```
////
@@ -61,7 +61,7 @@ Erstellen Sie Datei-Parameter, so wie Sie es auch mit `Body` und `Form` machen w
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
{!> ../../docs_src/request_files/tutorial001_an.py!}
```
////
@@ -75,7 +75,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/request_files/tutorial001.py!}
{!> ../../docs_src/request_files/tutorial001.py!}
```
////
@@ -109,7 +109,7 @@ Definieren Sie einen Datei-Parameter mit dem Typ `UploadFile`:
//// tab | Python 3.9+
```Python hl_lines="14"
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
{!> ../../docs_src/request_files/tutorial001_an_py39.py!}
```
////
@@ -117,7 +117,7 @@ Definieren Sie einen Datei-Parameter mit dem Typ `UploadFile`:
//// tab | Python 3.8+
```Python hl_lines="13"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
{!> ../../docs_src/request_files/tutorial001_an.py!}
```
////
@@ -131,7 +131,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="12"
{!> ../../../docs_src/request_files/tutorial001.py!}
{!> ../../docs_src/request_files/tutorial001.py!}
```
////
@@ -220,7 +220,7 @@ Sie können eine Datei optional machen, indem Sie Standard-Typannotationen verwe
//// tab | Python 3.10+
```Python hl_lines="9 17"
{!> ../../../docs_src/request_files/tutorial001_02_an_py310.py!}
{!> ../../docs_src/request_files/tutorial001_02_an_py310.py!}
```
////
@@ -228,7 +228,7 @@ Sie können eine Datei optional machen, indem Sie Standard-Typannotationen verwe
//// tab | Python 3.9+
```Python hl_lines="9 17"
{!> ../../../docs_src/request_files/tutorial001_02_an_py39.py!}
{!> ../../docs_src/request_files/tutorial001_02_an_py39.py!}
```
////
@@ -236,7 +236,7 @@ Sie können eine Datei optional machen, indem Sie Standard-Typannotationen verwe
//// tab | Python 3.8+
```Python hl_lines="10 18"
{!> ../../../docs_src/request_files/tutorial001_02_an.py!}
{!> ../../docs_src/request_files/tutorial001_02_an.py!}
```
////
@@ -250,7 +250,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7 15"
{!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
{!> ../../docs_src/request_files/tutorial001_02_py310.py!}
```
////
@@ -264,7 +264,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9 17"
{!> ../../../docs_src/request_files/tutorial001_02.py!}
{!> ../../docs_src/request_files/tutorial001_02.py!}
```
////
@@ -276,7 +276,7 @@ Sie können auch `File()` zusammen mit `UploadFile` verwenden, um zum Beispiel z
//// tab | Python 3.9+
```Python hl_lines="9 15"
{!> ../../../docs_src/request_files/tutorial001_03_an_py39.py!}
{!> ../../docs_src/request_files/tutorial001_03_an_py39.py!}
```
////
@@ -284,7 +284,7 @@ Sie können auch `File()` zusammen mit `UploadFile` verwenden, um zum Beispiel z
//// tab | Python 3.8+
```Python hl_lines="8 14"
{!> ../../../docs_src/request_files/tutorial001_03_an.py!}
{!> ../../docs_src/request_files/tutorial001_03_an.py!}
```
////
@@ -298,7 +298,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7 13"
{!> ../../../docs_src/request_files/tutorial001_03.py!}
{!> ../../docs_src/request_files/tutorial001_03.py!}
```
////
@@ -314,7 +314,7 @@ Um das zu machen, deklarieren Sie eine Liste von `bytes` oder `UploadFile`s:
//// tab | Python 3.9+
```Python hl_lines="10 15"
{!> ../../../docs_src/request_files/tutorial002_an_py39.py!}
{!> ../../docs_src/request_files/tutorial002_an_py39.py!}
```
////
@@ -322,7 +322,7 @@ Um das zu machen, deklarieren Sie eine Liste von `bytes` oder `UploadFile`s:
//// tab | Python 3.8+
```Python hl_lines="11 16"
{!> ../../../docs_src/request_files/tutorial002_an.py!}
{!> ../../docs_src/request_files/tutorial002_an.py!}
```
////
@@ -336,7 +336,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8 13"
{!> ../../../docs_src/request_files/tutorial002_py39.py!}
{!> ../../docs_src/request_files/tutorial002_py39.py!}
```
////
@@ -350,7 +350,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10 15"
{!> ../../../docs_src/request_files/tutorial002.py!}
{!> ../../docs_src/request_files/tutorial002.py!}
```
////
@@ -372,7 +372,7 @@ Und so wie zuvor können Sie `File()` verwenden, um zusätzliche Parameter zu se
//// tab | Python 3.9+
```Python hl_lines="11 18-20"
{!> ../../../docs_src/request_files/tutorial003_an_py39.py!}
{!> ../../docs_src/request_files/tutorial003_an_py39.py!}
```
////
@@ -380,7 +380,7 @@ Und so wie zuvor können Sie `File()` verwenden, um zusätzliche Parameter zu se
//// tab | Python 3.8+
```Python hl_lines="12 19-21"
{!> ../../../docs_src/request_files/tutorial003_an.py!}
{!> ../../docs_src/request_files/tutorial003_an.py!}
```
////
@@ -394,7 +394,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="9 16"
{!> ../../../docs_src/request_files/tutorial003_py39.py!}
{!> ../../docs_src/request_files/tutorial003_py39.py!}
```
////
@@ -408,7 +408,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="11 18"
{!> ../../../docs_src/request_files/tutorial003.py!}
{!> ../../docs_src/request_files/tutorial003.py!}
```
////

View File

@@ -15,7 +15,7 @@ Z. B. `pip install python-multipart`.
//// tab | Python 3.9+
```Python hl_lines="3"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
{!> ../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
```
////
@@ -23,7 +23,7 @@ Z. B. `pip install python-multipart`.
//// tab | Python 3.8+
```Python hl_lines="1"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
{!> ../../docs_src/request_forms_and_files/tutorial001_an.py!}
```
////
@@ -37,7 +37,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/request_forms_and_files/tutorial001.py!}
{!> ../../docs_src/request_forms_and_files/tutorial001.py!}
```
////
@@ -49,7 +49,7 @@ Erstellen Sie Datei- und Formularparameter, so wie Sie es auch mit `Body` und `Q
//// tab | Python 3.9+
```Python hl_lines="10-12"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
{!> ../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
```
////
@@ -57,7 +57,7 @@ Erstellen Sie Datei- und Formularparameter, so wie Sie es auch mit `Body` und `Q
//// tab | Python 3.8+
```Python hl_lines="9-11"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
{!> ../../docs_src/request_forms_and_files/tutorial001_an.py!}
```
////
@@ -71,7 +71,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="8"
{!> ../../../docs_src/request_forms_and_files/tutorial001.py!}
{!> ../../docs_src/request_forms_and_files/tutorial001.py!}
```
////

View File

@@ -17,7 +17,7 @@ Importieren Sie `Form` von `fastapi`:
//// tab | Python 3.9+
```Python hl_lines="3"
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
{!> ../../docs_src/request_forms/tutorial001_an_py39.py!}
```
////
@@ -25,7 +25,7 @@ Importieren Sie `Form` von `fastapi`:
//// tab | Python 3.8+
```Python hl_lines="1"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
{!> ../../docs_src/request_forms/tutorial001_an.py!}
```
////
@@ -39,7 +39,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1"
{!> ../../../docs_src/request_forms/tutorial001.py!}
{!> ../../docs_src/request_forms/tutorial001.py!}
```
////
@@ -51,7 +51,7 @@ Erstellen Sie Formular-Parameter, so wie Sie es auch mit `Body` und `Query` mach
//// tab | Python 3.9+
```Python hl_lines="9"
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
{!> ../../docs_src/request_forms/tutorial001_an_py39.py!}
```
////
@@ -59,7 +59,7 @@ Erstellen Sie Formular-Parameter, so wie Sie es auch mit `Body` und `Query` mach
//// tab | Python 3.8+
```Python hl_lines="8"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
{!> ../../docs_src/request_forms/tutorial001_an.py!}
```
////
@@ -73,7 +73,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7"
{!> ../../../docs_src/request_forms/tutorial001.py!}
{!> ../../docs_src/request_forms/tutorial001.py!}
```
////

View File

@@ -7,7 +7,7 @@ Hierbei können Sie **Typannotationen** genauso verwenden, wie Sie es bei Werten
//// tab | Python 3.10+
```Python hl_lines="16 21"
{!> ../../../docs_src/response_model/tutorial001_01_py310.py!}
{!> ../../docs_src/response_model/tutorial001_01_py310.py!}
```
////
@@ -15,7 +15,7 @@ Hierbei können Sie **Typannotationen** genauso verwenden, wie Sie es bei Werten
//// tab | Python 3.9+
```Python hl_lines="18 23"
{!> ../../../docs_src/response_model/tutorial001_01_py39.py!}
{!> ../../docs_src/response_model/tutorial001_01_py39.py!}
```
////
@@ -23,7 +23,7 @@ Hierbei können Sie **Typannotationen** genauso verwenden, wie Sie es bei Werten
//// tab | Python 3.8+
```Python hl_lines="18 23"
{!> ../../../docs_src/response_model/tutorial001_01.py!}
{!> ../../docs_src/response_model/tutorial001_01.py!}
```
////
@@ -62,7 +62,7 @@ Sie können `response_model` in jeder möglichen *Pfadoperation* verwenden:
//// tab | Python 3.10+
```Python hl_lines="17 22 24-27"
{!> ../../../docs_src/response_model/tutorial001_py310.py!}
{!> ../../docs_src/response_model/tutorial001_py310.py!}
```
////
@@ -70,7 +70,7 @@ Sie können `response_model` in jeder möglichen *Pfadoperation* verwenden:
//// tab | Python 3.9+
```Python hl_lines="17 22 24-27"
{!> ../../../docs_src/response_model/tutorial001_py39.py!}
{!> ../../docs_src/response_model/tutorial001_py39.py!}
```
////
@@ -78,7 +78,7 @@ Sie können `response_model` in jeder möglichen *Pfadoperation* verwenden:
//// tab | Python 3.8+
```Python hl_lines="17 22 24-27"
{!> ../../../docs_src/response_model/tutorial001.py!}
{!> ../../docs_src/response_model/tutorial001.py!}
```
////
@@ -116,7 +116,7 @@ Im Folgenden deklarieren wir ein `UserIn`-Modell; es enthält ein Klartext-Passw
//// tab | Python 3.10+
```Python hl_lines="7 9"
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
{!> ../../docs_src/response_model/tutorial002_py310.py!}
```
////
@@ -124,14 +124,14 @@ Im Folgenden deklarieren wir ein `UserIn`-Modell; es enthält ein Klartext-Passw
//// tab | Python 3.8+
```Python hl_lines="9 11"
{!> ../../../docs_src/response_model/tutorial002.py!}
{!> ../../docs_src/response_model/tutorial002.py!}
```
////
/// info
Um `EmailStr` zu verwenden, installieren Sie zuerst <a href="https://github.com/JoshData/python-email-validator" class="external-link" target="_blank">`email_validator`</a>.
Um `EmailStr` zu verwenden, installieren Sie zuerst <a href="https://github.com/JoshData/python-email-validator" class="external-link" target="_blank">`email-validator`</a>.
Z. B. `pip install email-validator`
oder `pip install pydantic[email]`.
@@ -143,7 +143,7 @@ Wir verwenden dieses Modell, um sowohl unsere Eingabe- als auch Ausgabedaten zu
//// tab | Python 3.10+
```Python hl_lines="16"
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
{!> ../../docs_src/response_model/tutorial002_py310.py!}
```
////
@@ -151,7 +151,7 @@ Wir verwenden dieses Modell, um sowohl unsere Eingabe- als auch Ausgabedaten zu
//// tab | Python 3.8+
```Python hl_lines="18"
{!> ../../../docs_src/response_model/tutorial002.py!}
{!> ../../docs_src/response_model/tutorial002.py!}
```
////
@@ -175,7 +175,7 @@ Wir können stattdessen ein Eingabemodell mit dem Klartext-Passwort, und ein Aus
//// tab | Python 3.10+
```Python hl_lines="9 11 16"
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
{!> ../../docs_src/response_model/tutorial003_py310.py!}
```
////
@@ -183,7 +183,7 @@ Wir können stattdessen ein Eingabemodell mit dem Klartext-Passwort, und ein Aus
//// tab | Python 3.8+
```Python hl_lines="9 11 16"
{!> ../../../docs_src/response_model/tutorial003.py!}
{!> ../../docs_src/response_model/tutorial003.py!}
```
////
@@ -193,7 +193,7 @@ Obwohl unsere *Pfadoperation-Funktion* hier denselben `user` von der Eingabe zur
//// tab | Python 3.10+
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
{!> ../../docs_src/response_model/tutorial003_py310.py!}
```
////
@@ -201,7 +201,7 @@ Obwohl unsere *Pfadoperation-Funktion* hier denselben `user` von der Eingabe zur
//// tab | Python 3.8+
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial003.py!}
{!> ../../docs_src/response_model/tutorial003.py!}
```
////
@@ -211,7 +211,7 @@ Obwohl unsere *Pfadoperation-Funktion* hier denselben `user` von der Eingabe zur
//// tab | Python 3.10+
```Python hl_lines="22"
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
{!> ../../docs_src/response_model/tutorial003_py310.py!}
```
////
@@ -219,7 +219,7 @@ Obwohl unsere *Pfadoperation-Funktion* hier denselben `user` von der Eingabe zur
//// tab | Python 3.8+
```Python hl_lines="22"
{!> ../../../docs_src/response_model/tutorial003.py!}
{!> ../../docs_src/response_model/tutorial003.py!}
```
////
@@ -249,7 +249,7 @@ Und in solchen Fällen können wir Klassen und Vererbung verwenden, um Vorteil a
//// tab | Python 3.10+
```Python hl_lines="7-10 13-14 18"
{!> ../../../docs_src/response_model/tutorial003_01_py310.py!}
{!> ../../docs_src/response_model/tutorial003_01_py310.py!}
```
////
@@ -257,7 +257,7 @@ Und in solchen Fällen können wir Klassen und Vererbung verwenden, um Vorteil a
//// tab | Python 3.8+
```Python hl_lines="9-13 15-16 20"
{!> ../../../docs_src/response_model/tutorial003_01.py!}
{!> ../../docs_src/response_model/tutorial003_01.py!}
```
////
@@ -303,7 +303,7 @@ Es kann Fälle geben, bei denen Sie etwas zurückgeben, das kein gültiges Pydan
Der häufigste Anwendungsfall ist, wenn Sie [eine Response direkt zurückgeben, wie es später im Handbuch für fortgeschrittene Benutzer erläutert wird](../advanced/response-directly.md){.internal-link target=_blank}.
```Python hl_lines="8 10-11"
{!> ../../../docs_src/response_model/tutorial003_02.py!}
{!> ../../docs_src/response_model/tutorial003_02.py!}
```
Dieser einfache Anwendungsfall wird automatisch von FastAPI gehandhabt, weil die Annotation des Rückgabetyps die Klasse (oder eine Unterklasse von) `Response` ist.
@@ -315,7 +315,7 @@ Und Tools werden auch glücklich sein, weil sowohl `RedirectResponse` als auch `
Sie können auch eine Unterklasse von `Response` in der Typannotation verwenden.
```Python hl_lines="8-9"
{!> ../../../docs_src/response_model/tutorial003_03.py!}
{!> ../../docs_src/response_model/tutorial003_03.py!}
```
Das wird ebenfalls funktionieren, weil `RedirectResponse` eine Unterklasse von `Response` ist, und FastAPI sich um diesen einfachen Anwendungsfall automatisch kümmert.
@@ -329,7 +329,7 @@ Das gleiche wird passieren, wenn Sie eine <abbr title='Eine Union mehrerer Typen
//// tab | Python 3.10+
```Python hl_lines="8"
{!> ../../../docs_src/response_model/tutorial003_04_py310.py!}
{!> ../../docs_src/response_model/tutorial003_04_py310.py!}
```
////
@@ -337,7 +337,7 @@ Das gleiche wird passieren, wenn Sie eine <abbr title='Eine Union mehrerer Typen
//// tab | Python 3.8+
```Python hl_lines="10"
{!> ../../../docs_src/response_model/tutorial003_04.py!}
{!> ../../docs_src/response_model/tutorial003_04.py!}
```
////
@@ -355,7 +355,7 @@ In diesem Fall können Sie die Generierung des Responsemodells abschalten, indem
//// tab | Python 3.10+
```Python hl_lines="7"
{!> ../../../docs_src/response_model/tutorial003_05_py310.py!}
{!> ../../docs_src/response_model/tutorial003_05_py310.py!}
```
////
@@ -363,7 +363,7 @@ In diesem Fall können Sie die Generierung des Responsemodells abschalten, indem
//// tab | Python 3.8+
```Python hl_lines="9"
{!> ../../../docs_src/response_model/tutorial003_05.py!}
{!> ../../docs_src/response_model/tutorial003_05.py!}
```
////
@@ -377,7 +377,7 @@ Ihr Responsemodell könnte Defaultwerte haben, wie:
//// tab | Python 3.10+
```Python hl_lines="9 11-12"
{!> ../../../docs_src/response_model/tutorial004_py310.py!}
{!> ../../docs_src/response_model/tutorial004_py310.py!}
```
////
@@ -385,7 +385,7 @@ Ihr Responsemodell könnte Defaultwerte haben, wie:
//// tab | Python 3.9+
```Python hl_lines="11 13-14"
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
{!> ../../docs_src/response_model/tutorial004_py39.py!}
```
////
@@ -393,7 +393,7 @@ Ihr Responsemodell könnte Defaultwerte haben, wie:
//// tab | Python 3.8+
```Python hl_lines="11 13-14"
{!> ../../../docs_src/response_model/tutorial004.py!}
{!> ../../docs_src/response_model/tutorial004.py!}
```
////
@@ -413,7 +413,7 @@ Sie können den *Pfadoperation-Dekorator*-Parameter `response_model_exclude_unse
//// tab | Python 3.10+
```Python hl_lines="22"
{!> ../../../docs_src/response_model/tutorial004_py310.py!}
{!> ../../docs_src/response_model/tutorial004_py310.py!}
```
////
@@ -421,7 +421,7 @@ Sie können den *Pfadoperation-Dekorator*-Parameter `response_model_exclude_unse
//// tab | Python 3.9+
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
{!> ../../docs_src/response_model/tutorial004_py39.py!}
```
////
@@ -429,7 +429,7 @@ Sie können den *Pfadoperation-Dekorator*-Parameter `response_model_exclude_unse
//// tab | Python 3.8+
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial004.py!}
{!> ../../docs_src/response_model/tutorial004.py!}
```
////
@@ -532,7 +532,7 @@ Das trifft auch auf `response_model_by_alias` zu, welches ähnlich funktioniert.
//// tab | Python 3.10+
```Python hl_lines="29 35"
{!> ../../../docs_src/response_model/tutorial005_py310.py!}
{!> ../../docs_src/response_model/tutorial005_py310.py!}
```
////
@@ -540,7 +540,7 @@ Das trifft auch auf `response_model_by_alias` zu, welches ähnlich funktioniert.
//// tab | Python 3.8+
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial005.py!}
{!> ../../docs_src/response_model/tutorial005.py!}
```
////
@@ -560,7 +560,7 @@ Wenn Sie vergessen, ein `set` zu verwenden, und stattdessen eine `list`e oder ei
//// tab | Python 3.10+
```Python hl_lines="29 35"
{!> ../../../docs_src/response_model/tutorial006_py310.py!}
{!> ../../docs_src/response_model/tutorial006_py310.py!}
```
////
@@ -568,7 +568,7 @@ Wenn Sie vergessen, ein `set` zu verwenden, und stattdessen eine `list`e oder ei
//// tab | Python 3.8+
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial006.py!}
{!> ../../docs_src/response_model/tutorial006.py!}
```
////

View File

@@ -9,7 +9,7 @@ So wie ein Responsemodell, können Sie auch einen HTTP-Statuscode für die Respo
* usw.
```Python hl_lines="6"
{!../../../docs_src/response_status_code/tutorial001.py!}
{!../../docs_src/response_status_code/tutorial001.py!}
```
/// note | "Hinweis"
@@ -77,7 +77,7 @@ Um mehr über Statuscodes zu lernen, und welcher wofür verwendet wird, lesen Si
Schauen wir uns das vorherige Beispiel noch einmal an:
```Python hl_lines="6"
{!../../../docs_src/response_status_code/tutorial001.py!}
{!../../docs_src/response_status_code/tutorial001.py!}
```
`201` ist der Statuscode für „Created“ („Erzeugt“).
@@ -87,7 +87,7 @@ Aber Sie müssen sich nicht daran erinnern, welcher dieser Codes was bedeutet.
Sie können die Hilfsvariablen von `fastapi.status` verwenden.
```Python hl_lines="1 6"
{!../../../docs_src/response_status_code/tutorial002.py!}
{!../../docs_src/response_status_code/tutorial002.py!}
```
Diese sind nur eine Annehmlichkeit und enthalten dieselbe Nummer, aber auf diese Weise können Sie die Autovervollständigung Ihres Editors verwenden, um sie zu finden:

View File

@@ -11,7 +11,7 @@ Sie können `examples` („Beispiele“) für ein Pydantic-Modell deklarieren, w
//// tab | Python 3.10+ Pydantic v2
```Python hl_lines="13-24"
{!> ../../../docs_src/schema_extra_example/tutorial001_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial001_py310.py!}
```
////
@@ -19,7 +19,7 @@ Sie können `examples` („Beispiele“) für ein Pydantic-Modell deklarieren, w
//// tab | Python 3.10+ Pydantic v1
```Python hl_lines="13-23"
{!> ../../../docs_src/schema_extra_example/tutorial001_py310_pv1.py!}
{!> ../../docs_src/schema_extra_example/tutorial001_py310_pv1.py!}
```
////
@@ -27,7 +27,7 @@ Sie können `examples` („Beispiele“) für ein Pydantic-Modell deklarieren, w
//// tab | Python 3.8+ Pydantic v2
```Python hl_lines="15-26"
{!> ../../../docs_src/schema_extra_example/tutorial001.py!}
{!> ../../docs_src/schema_extra_example/tutorial001.py!}
```
////
@@ -35,7 +35,7 @@ Sie können `examples` („Beispiele“) für ein Pydantic-Modell deklarieren, w
//// tab | Python 3.8+ Pydantic v1
```Python hl_lines="15-25"
{!> ../../../docs_src/schema_extra_example/tutorial001_pv1.py!}
{!> ../../docs_src/schema_extra_example/tutorial001_pv1.py!}
```
////
@@ -83,7 +83,7 @@ Wenn Sie `Field()` mit Pydantic-Modellen verwenden, können Sie ebenfalls zusät
//// tab | Python 3.10+
```Python hl_lines="2 8-11"
{!> ../../../docs_src/schema_extra_example/tutorial002_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial002_py310.py!}
```
////
@@ -91,7 +91,7 @@ Wenn Sie `Field()` mit Pydantic-Modellen verwenden, können Sie ebenfalls zusät
//// tab | Python 3.8+
```Python hl_lines="4 10-13"
{!> ../../../docs_src/schema_extra_example/tutorial002.py!}
{!> ../../docs_src/schema_extra_example/tutorial002.py!}
```
////
@@ -117,7 +117,7 @@ Hier übergeben wir `examples`, welches ein einzelnes Beispiel für die in `Body
//// tab | Python 3.10+
```Python hl_lines="22-29"
{!> ../../../docs_src/schema_extra_example/tutorial003_an_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial003_an_py310.py!}
```
////
@@ -125,7 +125,7 @@ Hier übergeben wir `examples`, welches ein einzelnes Beispiel für die in `Body
//// tab | Python 3.9+
```Python hl_lines="22-29"
{!> ../../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
{!> ../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
```
////
@@ -133,7 +133,7 @@ Hier übergeben wir `examples`, welches ein einzelnes Beispiel für die in `Body
//// tab | Python 3.8+
```Python hl_lines="23-30"
{!> ../../../docs_src/schema_extra_example/tutorial003_an.py!}
{!> ../../docs_src/schema_extra_example/tutorial003_an.py!}
```
////
@@ -147,7 +147,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="18-25"
{!> ../../../docs_src/schema_extra_example/tutorial003_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial003_py310.py!}
```
////
@@ -161,7 +161,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="20-27"
{!> ../../../docs_src/schema_extra_example/tutorial003.py!}
{!> ../../docs_src/schema_extra_example/tutorial003.py!}
```
////
@@ -179,7 +179,7 @@ Sie können natürlich auch mehrere `examples` übergeben:
//// tab | Python 3.10+
```Python hl_lines="23-38"
{!> ../../../docs_src/schema_extra_example/tutorial004_an_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial004_an_py310.py!}
```
////
@@ -187,7 +187,7 @@ Sie können natürlich auch mehrere `examples` übergeben:
//// tab | Python 3.9+
```Python hl_lines="23-38"
{!> ../../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
{!> ../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
```
////
@@ -195,7 +195,7 @@ Sie können natürlich auch mehrere `examples` übergeben:
//// tab | Python 3.8+
```Python hl_lines="24-39"
{!> ../../../docs_src/schema_extra_example/tutorial004_an.py!}
{!> ../../docs_src/schema_extra_example/tutorial004_an.py!}
```
////
@@ -209,7 +209,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19-34"
{!> ../../../docs_src/schema_extra_example/tutorial004_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial004_py310.py!}
```
////
@@ -223,7 +223,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="21-36"
{!> ../../../docs_src/schema_extra_example/tutorial004.py!}
{!> ../../docs_src/schema_extra_example/tutorial004.py!}
```
////
@@ -270,7 +270,7 @@ Sie können es so verwenden:
//// tab | Python 3.10+
```Python hl_lines="23-49"
{!> ../../../docs_src/schema_extra_example/tutorial005_an_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial005_an_py310.py!}
```
////
@@ -278,7 +278,7 @@ Sie können es so verwenden:
//// tab | Python 3.9+
```Python hl_lines="23-49"
{!> ../../../docs_src/schema_extra_example/tutorial005_an_py39.py!}
{!> ../../docs_src/schema_extra_example/tutorial005_an_py39.py!}
```
////
@@ -286,7 +286,7 @@ Sie können es so verwenden:
//// tab | Python 3.8+
```Python hl_lines="24-50"
{!> ../../../docs_src/schema_extra_example/tutorial005_an.py!}
{!> ../../docs_src/schema_extra_example/tutorial005_an.py!}
```
////
@@ -300,7 +300,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19-45"
{!> ../../../docs_src/schema_extra_example/tutorial005_py310.py!}
{!> ../../docs_src/schema_extra_example/tutorial005_py310.py!}
```
////
@@ -314,7 +314,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="21-47"
{!> ../../../docs_src/schema_extra_example/tutorial005.py!}
{!> ../../docs_src/schema_extra_example/tutorial005.py!}
```
////

View File

@@ -23,7 +23,7 @@ Kopieren Sie das Beispiel in eine Datei `main.py`:
//// tab | Python 3.9+
```Python
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
{!> ../../docs_src/security/tutorial001_an_py39.py!}
```
////
@@ -31,7 +31,7 @@ Kopieren Sie das Beispiel in eine Datei `main.py`:
//// tab | Python 3.8+
```Python
{!> ../../../docs_src/security/tutorial001_an.py!}
{!> ../../docs_src/security/tutorial001_an.py!}
```
////
@@ -45,7 +45,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python
{!> ../../../docs_src/security/tutorial001.py!}
{!> ../../docs_src/security/tutorial001.py!}
```
////
@@ -157,7 +157,7 @@ Wenn wir eine Instanz der Klasse `OAuth2PasswordBearer` erstellen, übergeben wi
//// tab | Python 3.9+
```Python hl_lines="8"
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
{!> ../../docs_src/security/tutorial001_an_py39.py!}
```
////
@@ -165,7 +165,7 @@ Wenn wir eine Instanz der Klasse `OAuth2PasswordBearer` erstellen, übergeben wi
//// tab | Python 3.8+
```Python hl_lines="7"
{!> ../../../docs_src/security/tutorial001_an.py!}
{!> ../../docs_src/security/tutorial001_an.py!}
```
////
@@ -179,7 +179,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6"
{!> ../../../docs_src/security/tutorial001.py!}
{!> ../../docs_src/security/tutorial001.py!}
```
////
@@ -223,7 +223,7 @@ Jetzt können Sie dieses `oauth2_scheme` als Abhängigkeit `Depends` übergeben.
//// tab | Python 3.9+
```Python hl_lines="12"
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
{!> ../../docs_src/security/tutorial001_an_py39.py!}
```
////
@@ -231,7 +231,7 @@ Jetzt können Sie dieses `oauth2_scheme` als Abhängigkeit `Depends` übergeben.
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/security/tutorial001_an.py!}
{!> ../../docs_src/security/tutorial001_an.py!}
```
////
@@ -245,7 +245,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/security/tutorial001.py!}
{!> ../../docs_src/security/tutorial001.py!}
```
////

View File

@@ -5,7 +5,7 @@ Im vorherigen Kapitel hat das Sicherheitssystem (das auf dem Dependency Injectio
//// tab | Python 3.9+
```Python hl_lines="12"
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
{!> ../../docs_src/security/tutorial001_an_py39.py!}
```
////
@@ -13,7 +13,7 @@ Im vorherigen Kapitel hat das Sicherheitssystem (das auf dem Dependency Injectio
//// tab | Python 3.8+
```Python hl_lines="11"
{!> ../../../docs_src/security/tutorial001_an.py!}
{!> ../../docs_src/security/tutorial001_an.py!}
```
////
@@ -27,7 +27,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="10"
{!> ../../../docs_src/security/tutorial001.py!}
{!> ../../docs_src/security/tutorial001.py!}
```
////
@@ -45,7 +45,7 @@ So wie wir Pydantic zum Deklarieren von Bodys verwenden, können wir es auch üb
//// tab | Python 3.10+
```Python hl_lines="5 12-16"
{!> ../../../docs_src/security/tutorial002_an_py310.py!}
{!> ../../docs_src/security/tutorial002_an_py310.py!}
```
////
@@ -53,7 +53,7 @@ So wie wir Pydantic zum Deklarieren von Bodys verwenden, können wir es auch üb
//// tab | Python 3.9+
```Python hl_lines="5 12-16"
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
{!> ../../docs_src/security/tutorial002_an_py39.py!}
```
////
@@ -61,7 +61,7 @@ So wie wir Pydantic zum Deklarieren von Bodys verwenden, können wir es auch üb
//// tab | Python 3.8+
```Python hl_lines="5 13-17"
{!> ../../../docs_src/security/tutorial002_an.py!}
{!> ../../docs_src/security/tutorial002_an.py!}
```
////
@@ -75,7 +75,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3 10-14"
{!> ../../../docs_src/security/tutorial002_py310.py!}
{!> ../../docs_src/security/tutorial002_py310.py!}
```
////
@@ -89,7 +89,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="5 12-16"
{!> ../../../docs_src/security/tutorial002.py!}
{!> ../../docs_src/security/tutorial002.py!}
```
////
@@ -107,7 +107,7 @@ So wie wir es zuvor in der *Pfadoperation* direkt gemacht haben, erhält unsere
//// tab | Python 3.10+
```Python hl_lines="25"
{!> ../../../docs_src/security/tutorial002_an_py310.py!}
{!> ../../docs_src/security/tutorial002_an_py310.py!}
```
////
@@ -115,7 +115,7 @@ So wie wir es zuvor in der *Pfadoperation* direkt gemacht haben, erhält unsere
//// tab | Python 3.9+
```Python hl_lines="25"
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
{!> ../../docs_src/security/tutorial002_an_py39.py!}
```
////
@@ -123,7 +123,7 @@ So wie wir es zuvor in der *Pfadoperation* direkt gemacht haben, erhält unsere
//// tab | Python 3.8+
```Python hl_lines="26"
{!> ../../../docs_src/security/tutorial002_an.py!}
{!> ../../docs_src/security/tutorial002_an.py!}
```
////
@@ -137,7 +137,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="23"
{!> ../../../docs_src/security/tutorial002_py310.py!}
{!> ../../docs_src/security/tutorial002_py310.py!}
```
////
@@ -151,7 +151,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="25"
{!> ../../../docs_src/security/tutorial002.py!}
{!> ../../docs_src/security/tutorial002.py!}
```
////
@@ -163,7 +163,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.10+
```Python hl_lines="19-22 26-27"
{!> ../../../docs_src/security/tutorial002_an_py310.py!}
{!> ../../docs_src/security/tutorial002_an_py310.py!}
```
////
@@ -171,7 +171,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.9+
```Python hl_lines="19-22 26-27"
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
{!> ../../docs_src/security/tutorial002_an_py39.py!}
```
////
@@ -179,7 +179,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+
```Python hl_lines="20-23 27-28"
{!> ../../../docs_src/security/tutorial002_an.py!}
{!> ../../docs_src/security/tutorial002_an.py!}
```
////
@@ -193,7 +193,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="17-20 24-25"
{!> ../../../docs_src/security/tutorial002_py310.py!}
{!> ../../docs_src/security/tutorial002_py310.py!}
```
////
@@ -207,7 +207,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="19-22 26-27"
{!> ../../../docs_src/security/tutorial002.py!}
{!> ../../docs_src/security/tutorial002.py!}
```
////
@@ -219,7 +219,7 @@ Und jetzt können wir wiederum `Depends` mit unserem `get_current_user` in der *
//// tab | Python 3.10+
```Python hl_lines="31"
{!> ../../../docs_src/security/tutorial002_an_py310.py!}
{!> ../../docs_src/security/tutorial002_an_py310.py!}
```
////
@@ -227,7 +227,7 @@ Und jetzt können wir wiederum `Depends` mit unserem `get_current_user` in der *
//// tab | Python 3.9+
```Python hl_lines="31"
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
{!> ../../docs_src/security/tutorial002_an_py39.py!}
```
////
@@ -235,7 +235,7 @@ Und jetzt können wir wiederum `Depends` mit unserem `get_current_user` in der *
//// tab | Python 3.8+
```Python hl_lines="32"
{!> ../../../docs_src/security/tutorial002_an.py!}
{!> ../../docs_src/security/tutorial002_an.py!}
```
////
@@ -249,7 +249,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="29"
{!> ../../../docs_src/security/tutorial002_py310.py!}
{!> ../../docs_src/security/tutorial002_py310.py!}
```
////
@@ -263,7 +263,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="31"
{!> ../../../docs_src/security/tutorial002.py!}
{!> ../../docs_src/security/tutorial002.py!}
```
////
@@ -323,7 +323,7 @@ Und alle diese Tausenden von *Pfadoperationen* können nur drei Zeilen lang sein
//// tab | Python 3.10+
```Python hl_lines="30-32"
{!> ../../../docs_src/security/tutorial002_an_py310.py!}
{!> ../../docs_src/security/tutorial002_an_py310.py!}
```
////
@@ -331,7 +331,7 @@ Und alle diese Tausenden von *Pfadoperationen* können nur drei Zeilen lang sein
//// tab | Python 3.9+
```Python hl_lines="30-32"
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
{!> ../../docs_src/security/tutorial002_an_py39.py!}
```
////
@@ -339,7 +339,7 @@ Und alle diese Tausenden von *Pfadoperationen* können nur drei Zeilen lang sein
//// tab | Python 3.8+
```Python hl_lines="31-33"
{!> ../../../docs_src/security/tutorial002_an.py!}
{!> ../../docs_src/security/tutorial002_an.py!}
```
////
@@ -353,7 +353,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="28-30"
{!> ../../../docs_src/security/tutorial002_py310.py!}
{!> ../../docs_src/security/tutorial002_py310.py!}
```
////
@@ -367,7 +367,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="30-32"
{!> ../../../docs_src/security/tutorial002.py!}
{!> ../../docs_src/security/tutorial002.py!}
```
////

View File

@@ -121,7 +121,7 @@ Und noch eine, um einen Benutzer zu authentifizieren und zurückzugeben.
//// tab | Python 3.10+
```Python hl_lines="7 48 55-56 59-60 69-75"
{!> ../../../docs_src/security/tutorial004_an_py310.py!}
{!> ../../docs_src/security/tutorial004_an_py310.py!}
```
////
@@ -129,7 +129,7 @@ Und noch eine, um einen Benutzer zu authentifizieren und zurückzugeben.
//// tab | Python 3.9+
```Python hl_lines="7 48 55-56 59-60 69-75"
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
{!> ../../docs_src/security/tutorial004_an_py39.py!}
```
////
@@ -137,7 +137,7 @@ Und noch eine, um einen Benutzer zu authentifizieren und zurückzugeben.
//// tab | Python 3.8+
```Python hl_lines="7 49 56-57 60-61 70-76"
{!> ../../../docs_src/security/tutorial004_an.py!}
{!> ../../docs_src/security/tutorial004_an.py!}
```
////
@@ -151,7 +151,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6 47 54-55 58-59 68-74"
{!> ../../../docs_src/security/tutorial004_py310.py!}
{!> ../../docs_src/security/tutorial004_py310.py!}
```
////
@@ -165,7 +165,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="7 48 55-56 59-60 69-75"
{!> ../../../docs_src/security/tutorial004.py!}
{!> ../../docs_src/security/tutorial004.py!}
```
////
@@ -207,7 +207,7 @@ Erstellen Sie eine Hilfsfunktion, um einen neuen Zugriffstoken zu generieren.
//// tab | Python 3.10+
```Python hl_lines="6 12-14 28-30 78-86"
{!> ../../../docs_src/security/tutorial004_an_py310.py!}
{!> ../../docs_src/security/tutorial004_an_py310.py!}
```
////
@@ -215,7 +215,7 @@ Erstellen Sie eine Hilfsfunktion, um einen neuen Zugriffstoken zu generieren.
//// tab | Python 3.9+
```Python hl_lines="6 12-14 28-30 78-86"
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
{!> ../../docs_src/security/tutorial004_an_py39.py!}
```
////
@@ -223,7 +223,7 @@ Erstellen Sie eine Hilfsfunktion, um einen neuen Zugriffstoken zu generieren.
//// tab | Python 3.8+
```Python hl_lines="6 13-15 29-31 79-87"
{!> ../../../docs_src/security/tutorial004_an.py!}
{!> ../../docs_src/security/tutorial004_an.py!}
```
////
@@ -237,7 +237,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="5 11-13 27-29 77-85"
{!> ../../../docs_src/security/tutorial004_py310.py!}
{!> ../../docs_src/security/tutorial004_py310.py!}
```
////
@@ -251,7 +251,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="6 12-14 28-30 78-86"
{!> ../../../docs_src/security/tutorial004.py!}
{!> ../../docs_src/security/tutorial004.py!}
```
////
@@ -267,7 +267,7 @@ Wenn der Token ungültig ist, geben Sie sofort einen HTTP-Fehler zurück.
//// tab | Python 3.10+
```Python hl_lines="89-106"
{!> ../../../docs_src/security/tutorial004_an_py310.py!}
{!> ../../docs_src/security/tutorial004_an_py310.py!}
```
////
@@ -275,7 +275,7 @@ Wenn der Token ungültig ist, geben Sie sofort einen HTTP-Fehler zurück.
//// tab | Python 3.9+
```Python hl_lines="89-106"
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
{!> ../../docs_src/security/tutorial004_an_py39.py!}
```
////
@@ -283,7 +283,7 @@ Wenn der Token ungültig ist, geben Sie sofort einen HTTP-Fehler zurück.
//// tab | Python 3.8+
```Python hl_lines="90-107"
{!> ../../../docs_src/security/tutorial004_an.py!}
{!> ../../docs_src/security/tutorial004_an.py!}
```
////
@@ -297,7 +297,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="88-105"
{!> ../../../docs_src/security/tutorial004_py310.py!}
{!> ../../docs_src/security/tutorial004_py310.py!}
```
////
@@ -311,7 +311,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="89-106"
{!> ../../../docs_src/security/tutorial004.py!}
{!> ../../docs_src/security/tutorial004.py!}
```
////
@@ -325,7 +325,7 @@ Erstellen Sie einen echten JWT-Zugriffstoken und geben Sie ihn zurück.
//// tab | Python 3.10+
```Python hl_lines="117-132"
{!> ../../../docs_src/security/tutorial004_an_py310.py!}
{!> ../../docs_src/security/tutorial004_an_py310.py!}
```
////
@@ -333,7 +333,7 @@ Erstellen Sie einen echten JWT-Zugriffstoken und geben Sie ihn zurück.
//// tab | Python 3.9+
```Python hl_lines="117-132"
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
{!> ../../docs_src/security/tutorial004_an_py39.py!}
```
////
@@ -341,7 +341,7 @@ Erstellen Sie einen echten JWT-Zugriffstoken und geben Sie ihn zurück.
//// tab | Python 3.8+
```Python hl_lines="118-133"
{!> ../../../docs_src/security/tutorial004_an.py!}
{!> ../../docs_src/security/tutorial004_an.py!}
```
////
@@ -355,7 +355,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="114-129"
{!> ../../../docs_src/security/tutorial004_py310.py!}
{!> ../../docs_src/security/tutorial004_py310.py!}
```
////
@@ -369,7 +369,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="115-130"
{!> ../../../docs_src/security/tutorial004.py!}
{!> ../../docs_src/security/tutorial004.py!}
```
////

View File

@@ -55,7 +55,7 @@ Importieren Sie zunächst `OAuth2PasswordRequestForm` und verwenden Sie es als A
//// tab | Python 3.10+
```Python hl_lines="4 78"
{!> ../../../docs_src/security/tutorial003_an_py310.py!}
{!> ../../docs_src/security/tutorial003_an_py310.py!}
```
////
@@ -63,7 +63,7 @@ Importieren Sie zunächst `OAuth2PasswordRequestForm` und verwenden Sie es als A
//// tab | Python 3.9+
```Python hl_lines="4 78"
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
{!> ../../docs_src/security/tutorial003_an_py39.py!}
```
////
@@ -71,7 +71,7 @@ Importieren Sie zunächst `OAuth2PasswordRequestForm` und verwenden Sie es als A
//// tab | Python 3.8+
```Python hl_lines="4 79"
{!> ../../../docs_src/security/tutorial003_an.py!}
{!> ../../docs_src/security/tutorial003_an.py!}
```
////
@@ -85,7 +85,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="2 74"
{!> ../../../docs_src/security/tutorial003_py310.py!}
{!> ../../docs_src/security/tutorial003_py310.py!}
```
////
@@ -99,7 +99,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="4 76"
{!> ../../../docs_src/security/tutorial003.py!}
{!> ../../docs_src/security/tutorial003.py!}
```
////
@@ -153,7 +153,7 @@ Für den Fehler verwenden wir die Exception `HTTPException`:
//// tab | Python 3.10+
```Python hl_lines="3 79-81"
{!> ../../../docs_src/security/tutorial003_an_py310.py!}
{!> ../../docs_src/security/tutorial003_an_py310.py!}
```
////
@@ -161,7 +161,7 @@ Für den Fehler verwenden wir die Exception `HTTPException`:
//// tab | Python 3.9+
```Python hl_lines="3 79-81"
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
{!> ../../docs_src/security/tutorial003_an_py39.py!}
```
////
@@ -169,7 +169,7 @@ Für den Fehler verwenden wir die Exception `HTTPException`:
//// tab | Python 3.8+
```Python hl_lines="3 80-82"
{!> ../../../docs_src/security/tutorial003_an.py!}
{!> ../../docs_src/security/tutorial003_an.py!}
```
////
@@ -183,7 +183,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="1 75-77"
{!> ../../../docs_src/security/tutorial003_py310.py!}
{!> ../../docs_src/security/tutorial003_py310.py!}
```
////
@@ -197,7 +197,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="3 77-79"
{!> ../../../docs_src/security/tutorial003.py!}
{!> ../../docs_src/security/tutorial003.py!}
```
////
@@ -229,7 +229,7 @@ Der Dieb kann also nicht versuchen, die gleichen Passwörter in einem anderen Sy
//// tab | Python 3.10+
```Python hl_lines="82-85"
{!> ../../../docs_src/security/tutorial003_an_py310.py!}
{!> ../../docs_src/security/tutorial003_an_py310.py!}
```
////
@@ -237,7 +237,7 @@ Der Dieb kann also nicht versuchen, die gleichen Passwörter in einem anderen Sy
//// tab | Python 3.9+
```Python hl_lines="82-85"
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
{!> ../../docs_src/security/tutorial003_an_py39.py!}
```
////
@@ -245,7 +245,7 @@ Der Dieb kann also nicht versuchen, die gleichen Passwörter in einem anderen Sy
//// tab | Python 3.8+
```Python hl_lines="83-86"
{!> ../../../docs_src/security/tutorial003_an.py!}
{!> ../../docs_src/security/tutorial003_an.py!}
```
////
@@ -259,7 +259,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="78-81"
{!> ../../../docs_src/security/tutorial003_py310.py!}
{!> ../../docs_src/security/tutorial003_py310.py!}
```
////
@@ -273,7 +273,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="80-83"
{!> ../../../docs_src/security/tutorial003.py!}
{!> ../../docs_src/security/tutorial003.py!}
```
////
@@ -321,7 +321,7 @@ Aber konzentrieren wir uns zunächst auf die spezifischen Details, die wir benö
//// tab | Python 3.10+
```Python hl_lines="87"
{!> ../../../docs_src/security/tutorial003_an_py310.py!}
{!> ../../docs_src/security/tutorial003_an_py310.py!}
```
////
@@ -329,7 +329,7 @@ Aber konzentrieren wir uns zunächst auf die spezifischen Details, die wir benö
//// tab | Python 3.9+
```Python hl_lines="87"
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
{!> ../../docs_src/security/tutorial003_an_py39.py!}
```
////
@@ -337,7 +337,7 @@ Aber konzentrieren wir uns zunächst auf die spezifischen Details, die wir benö
//// tab | Python 3.8+
```Python hl_lines="88"
{!> ../../../docs_src/security/tutorial003_an.py!}
{!> ../../docs_src/security/tutorial003_an.py!}
```
////
@@ -351,7 +351,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="83"
{!> ../../../docs_src/security/tutorial003_py310.py!}
{!> ../../docs_src/security/tutorial003_py310.py!}
```
////
@@ -365,7 +365,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="85"
{!> ../../../docs_src/security/tutorial003.py!}
{!> ../../docs_src/security/tutorial003.py!}
```
////
@@ -397,7 +397,7 @@ In unserem Endpunkt erhalten wir also nur dann einen Benutzer, wenn der Benutzer
//// tab | Python 3.10+
```Python hl_lines="58-66 69-74 94"
{!> ../../../docs_src/security/tutorial003_an_py310.py!}
{!> ../../docs_src/security/tutorial003_an_py310.py!}
```
////
@@ -405,7 +405,7 @@ In unserem Endpunkt erhalten wir also nur dann einen Benutzer, wenn der Benutzer
//// tab | Python 3.9+
```Python hl_lines="58-66 69-74 94"
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
{!> ../../docs_src/security/tutorial003_an_py39.py!}
```
////
@@ -413,7 +413,7 @@ In unserem Endpunkt erhalten wir also nur dann einen Benutzer, wenn der Benutzer
//// tab | Python 3.8+
```Python hl_lines="59-67 70-75 95"
{!> ../../../docs_src/security/tutorial003_an.py!}
{!> ../../docs_src/security/tutorial003_an.py!}
```
////
@@ -427,7 +427,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="56-64 67-70 88"
{!> ../../../docs_src/security/tutorial003_py310.py!}
{!> ../../docs_src/security/tutorial003_py310.py!}
```
////
@@ -441,7 +441,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python hl_lines="58-66 69-72 90"
{!> ../../../docs_src/security/tutorial003.py!}
{!> ../../docs_src/security/tutorial003.py!}
```
////

View File

@@ -8,7 +8,7 @@ Mit `StaticFiles` können Sie statische Dateien aus einem Verzeichnis automatisc
* „Mounten“ Sie eine `StaticFiles()`-Instanz in einem bestimmten Pfad.
```Python hl_lines="2 6"
{!../../../docs_src/static_files/tutorial001.py!}
{!../../docs_src/static_files/tutorial001.py!}
```
/// note | "Technische Details"

View File

@@ -27,7 +27,7 @@ Verwenden Sie das `TestClient`-Objekt auf die gleiche Weise wie `httpx`.
Schreiben Sie einfache `assert`-Anweisungen mit den Standard-Python-Ausdrücken, die Sie überprüfen müssen (wiederum, Standard-`pytest`).
```Python hl_lines="2 12 15-18"
{!../../../docs_src/app_testing/tutorial001.py!}
{!../../docs_src/app_testing/tutorial001.py!}
```
/// tip | "Tipp"
@@ -75,7 +75,7 @@ In der Datei `main.py` haben Sie Ihre **FastAPI**-Anwendung:
```Python
{!../../../docs_src/app_testing/main.py!}
{!../../docs_src/app_testing/main.py!}
```
### Testdatei
@@ -93,7 +93,7 @@ Dann könnten Sie eine Datei `test_main.py` mit Ihren Tests haben. Sie könnte s
Da sich diese Datei im selben Package befindet, können Sie relative Importe verwenden, um das Objekt `app` aus dem `main`-Modul (`main.py`) zu importieren:
```Python hl_lines="3"
{!../../../docs_src/app_testing/test_main.py!}
{!../../docs_src/app_testing/test_main.py!}
```
... und haben den Code für die Tests wie zuvor.
@@ -125,7 +125,7 @@ Beide *Pfadoperationen* erfordern einen `X-Token`-Header.
//// tab | Python 3.10+
```Python
{!> ../../../docs_src/app_testing/app_b_an_py310/main.py!}
{!> ../../docs_src/app_testing/app_b_an_py310/main.py!}
```
////
@@ -133,7 +133,7 @@ Beide *Pfadoperationen* erfordern einen `X-Token`-Header.
//// tab | Python 3.9+
```Python
{!> ../../../docs_src/app_testing/app_b_an_py39/main.py!}
{!> ../../docs_src/app_testing/app_b_an_py39/main.py!}
```
////
@@ -141,7 +141,7 @@ Beide *Pfadoperationen* erfordern einen `X-Token`-Header.
//// tab | Python 3.8+
```Python
{!> ../../../docs_src/app_testing/app_b_an/main.py!}
{!> ../../docs_src/app_testing/app_b_an/main.py!}
```
////
@@ -155,7 +155,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python
{!> ../../../docs_src/app_testing/app_b_py310/main.py!}
{!> ../../docs_src/app_testing/app_b_py310/main.py!}
```
////
@@ -169,7 +169,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python
{!> ../../../docs_src/app_testing/app_b/main.py!}
{!> ../../docs_src/app_testing/app_b/main.py!}
```
////
@@ -179,7 +179,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
Anschließend könnten Sie `test_main.py` mit den erweiterten Tests aktualisieren:
```Python
{!> ../../../docs_src/app_testing/app_b/test_main.py!}
{!> ../../docs_src/app_testing/app_b/test_main.py!}
```
Wenn Sie möchten, dass der Client Informationen im Request übergibt und Sie nicht wissen, wie das geht, können Sie suchen (googeln), wie es mit `httpx` gemacht wird, oder sogar, wie es mit `requests` gemacht wird, da das Design von HTTPX auf dem Design von Requests basiert.

View File

@@ -27,7 +27,7 @@
🖼, 📣 1⃣ 📨 ⏮️ 👔 📟 `404` &amp; Pydantic 🏷 `Message`, 👆 💪 ✍:
```Python hl_lines="18 22"
{!../../../docs_src/additional_responses/tutorial001.py!}
{!../../docs_src/additional_responses/tutorial001.py!}
```
/// note
@@ -178,7 +178,7 @@
🖼, 👆 💪 🚮 🌖 📻 🆎 `image/png`, 📣 👈 👆 *➡ 🛠️* 💪 📨 🎻 🎚 (⏮️ 📻 🆎 `application/json`) ⚖️ 🇩🇴 🖼:
```Python hl_lines="19-24 28"
{!../../../docs_src/additional_responses/tutorial002.py!}
{!../../docs_src/additional_responses/tutorial002.py!}
```
/// note
@@ -208,7 +208,7 @@
&amp; 📨 ⏮️ 👔 📟 `200` 👈 ⚙️ 👆 `response_model`, ✋️ 🔌 🛃 `example`:
```Python hl_lines="20-31"
{!../../../docs_src/additional_responses/tutorial003.py!}
{!../../docs_src/additional_responses/tutorial003.py!}
```
⚫️ 🔜 🌐 🌀 &amp; 🔌 👆 🗄, &amp; 🎦 🛠️ 🩺:
@@ -244,7 +244,7 @@ new_dict = {**old_dict, "new key": "new value"}
🖼:
```Python hl_lines="13-17 26"
{!../../../docs_src/additional_responses/tutorial004.py!}
{!../../docs_src/additional_responses/tutorial004.py!}
```
## 🌖 🔃 🗄 📨

View File

@@ -15,7 +15,7 @@
🏆 👈, 🗄 `JSONResponse`, &amp; 📨 👆 🎚 📤 🔗, ⚒ `status_code` 👈 👆 💚:
```Python hl_lines="4 25"
{!../../../docs_src/additional_status_codes/tutorial001.py!}
{!../../docs_src/additional_status_codes/tutorial001.py!}
```
/// warning

View File

@@ -19,7 +19,7 @@
👈, 👥 📣 👩‍🔬 `__call__`:
```Python hl_lines="10"
{!../../../docs_src/dependencies/tutorial011.py!}
{!../../docs_src/dependencies/tutorial011.py!}
```
👉 💼, 👉 `__call__` ⚫️❔ **FastAPI** 🔜 ⚙️ ✅ 🌖 🔢 &amp; 🎧-🔗, &amp; 👉 ⚫️❔ 🔜 🤙 🚶‍♀️ 💲 🔢 👆 *➡ 🛠️ 🔢* ⏪.
@@ -29,7 +29,7 @@
&amp; 🔜, 👥 💪 ⚙️ `__init__` 📣 🔢 👐 👈 👥 💪 ⚙️ "🔗" 🔗:
```Python hl_lines="7"
{!../../../docs_src/dependencies/tutorial011.py!}
{!../../docs_src/dependencies/tutorial011.py!}
```
👉 💼, **FastAPI** 🏆 🚫 ⏱ 👆 ⚖️ 💅 🔃 `__init__`, 👥 🔜 ⚙️ ⚫️ 🔗 👆 📟.
@@ -39,7 +39,7 @@
👥 💪 ✍ 👐 👉 🎓 ⏮️:
```Python hl_lines="16"
{!../../../docs_src/dependencies/tutorial011.py!}
{!../../docs_src/dependencies/tutorial011.py!}
```
&amp; 👈 🌌 👥 💪 "🔗" 👆 🔗, 👈 🔜 ✔️ `"bar"` 🔘 ⚫️, 🔢 `checker.fixed_content`.
@@ -57,7 +57,7 @@ checker(q="somequery")
...&amp; 🚶‍♀️ ⚫️❔ 👈 📨 💲 🔗 👆 *➡ 🛠️ 🔢* 🔢 `fixed_content_included`:
```Python hl_lines="20"
{!../../../docs_src/dependencies/tutorial011.py!}
{!../../docs_src/dependencies/tutorial011.py!}
```
/// tip

View File

@@ -33,13 +33,13 @@
📁 `main.py` 🔜 ✔️:
```Python
{!../../../docs_src/async_tests/main.py!}
{!../../docs_src/async_tests/main.py!}
```
📁 `test_main.py` 🔜 ✔️ 💯 `main.py`, ⚫️ 💪 👀 💖 👉 🔜:
```Python
{!../../../docs_src/async_tests/test_main.py!}
{!../../docs_src/async_tests/test_main.py!}
```
## 🏃 ⚫️
@@ -61,7 +61,7 @@ $ pytest
📑 `@pytest.mark.anyio` 💬 ✳ 👈 👉 💯 🔢 🔜 🤙 🔁:
```Python hl_lines="7"
{!../../../docs_src/async_tests/test_main.py!}
{!../../docs_src/async_tests/test_main.py!}
```
/// tip
@@ -72,8 +72,8 @@ $ pytest
⤴️ 👥 💪 ✍ `AsyncClient` ⏮️ 📱, &amp; 📨 🔁 📨 ⚫️, ⚙️ `await`.
```Python hl_lines="9-10"
{!../../../docs_src/async_tests/test_main.py!}
```Python hl_lines="9-12"
{!../../docs_src/async_tests/test_main.py!}
```
👉 🌓:

View File

@@ -95,7 +95,7 @@ $ uvicorn main:app --root-path /api/v1
📥 👥 ✅ ⚫️ 📧 🎦 🎯.
```Python hl_lines="8"
{!../../../docs_src/behind_a_proxy/tutorial001.py!}
{!../../docs_src/behind_a_proxy/tutorial001.py!}
```
⤴️, 🚥 👆 ▶️ Uvicorn ⏮️:
@@ -124,7 +124,7 @@ $ uvicorn main:app --root-path /api/v1
👐, 🚥 👆 🚫 ✔️ 🌌 🚚 📋 ⏸ 🎛 💖 `--root-path` ⚖️ 🌓, 👆 💪 ⚒ `root_path` 🔢 🕐❔ 🏗 👆 FastAPI 📱:
```Python hl_lines="3"
{!../../../docs_src/behind_a_proxy/tutorial002.py!}
{!../../docs_src/behind_a_proxy/tutorial002.py!}
```
🚶‍♀️ `root_path` `FastAPI` 🔜 🌓 🚶‍♀️ `--root-path` 📋 ⏸ 🎛 Uvicorn ⚖️ Hypercorn.
@@ -306,7 +306,7 @@ $ uvicorn main:app --root-path /api/v1
🖼:
```Python hl_lines="4-7"
{!../../../docs_src/behind_a_proxy/tutorial003.py!}
{!../../docs_src/behind_a_proxy/tutorial003.py!}
```
🔜 🏗 🗄 🔗 💖:
@@ -355,7 +355,7 @@ $ uvicorn main:app --root-path /api/v1
🚥 👆 🚫 💚 **FastAPI** 🔌 🏧 💽 ⚙️ `root_path`, 👆 💪 ⚙️ 🔢 `root_path_in_servers=False`:
```Python hl_lines="9"
{!../../../docs_src/behind_a_proxy/tutorial004.py!}
{!../../docs_src/behind_a_proxy/tutorial004.py!}
```
&amp; ⤴️ ⚫️ 🏆 🚫 🔌 ⚫️ 🗄 🔗.

View File

@@ -31,7 +31,7 @@
✋️ 🚥 👆 🎯 👈 🎚 👈 👆 🛬 **🎻 ⏮️ 🎻**, 👆 💪 🚶‍♀️ ⚫️ 🔗 📨 🎓 &amp; ❎ 🌥 👈 FastAPI 🔜 ✔️ 🚶‍♀️ 👆 📨 🎚 🔘 `jsonable_encoder` ⏭ 🚶‍♀️ ⚫️ 📨 🎓.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001b.py!}
{!../../docs_src/custom_response/tutorial001b.py!}
```
/// info
@@ -58,7 +58,7 @@
* 🚶‍♀️ `HTMLResponse` 🔢 `response_class` 👆 *➡ 🛠️ 👨‍🎨*.
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial002.py!}
{!../../docs_src/custom_response/tutorial002.py!}
```
/// info
@@ -78,7 +78,7 @@
🎏 🖼 ⚪️➡️ 🔛, 🛬 `HTMLResponse`, 💪 👀 💖:
```Python hl_lines="2 7 19"
{!../../../docs_src/custom_response/tutorial003.py!}
{!../../docs_src/custom_response/tutorial003.py!}
```
/// warning
@@ -104,7 +104,7 @@
🖼, ⚫️ 💪 🕳 💖:
```Python hl_lines="7 21 23"
{!../../../docs_src/custom_response/tutorial004.py!}
{!../../docs_src/custom_response/tutorial004.py!}
```
👉 🖼, 🔢 `generate_html_response()` ⏪ 🏗 &amp; 📨 `Response` ↩️ 🛬 🕸 `str`.
@@ -145,7 +145,7 @@
FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎 🎚, ⚓️ 🔛 = &amp; 🔁 = ✍ 🆎.
```Python hl_lines="1 18"
{!../../../docs_src/response_directly/tutorial002.py!}
{!../../docs_src/response_directly/tutorial002.py!}
```
### `HTMLResponse`
@@ -157,7 +157,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
✊ ✍ ⚖️ 🔢 &amp; 📨 ✅ ✍ 📨.
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial005.py!}
{!../../docs_src/custom_response/tutorial005.py!}
```
### `JSONResponse`
@@ -181,7 +181,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
///
```Python hl_lines="2 7"
{!../../../docs_src/custom_response/tutorial001.py!}
{!../../docs_src/custom_response/tutorial001.py!}
```
/// tip
@@ -197,7 +197,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
👆 💪 📨 `RedirectResponse` 🔗:
```Python hl_lines="2 9"
{!../../../docs_src/custom_response/tutorial006.py!}
{!../../docs_src/custom_response/tutorial006.py!}
```
---
@@ -206,7 +206,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial006b.py!}
{!../../docs_src/custom_response/tutorial006b.py!}
```
🚥 👆 👈, ⤴️ 👆 💪 📨 📛 🔗 ⚪️➡️ 👆 *➡ 🛠️* 🔢.
@@ -218,7 +218,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
👆 💪 ⚙️ `status_code` 🔢 🌀 ⏮️ `response_class` 🔢:
```Python hl_lines="2 7 9"
{!../../../docs_src/custom_response/tutorial006c.py!}
{!../../docs_src/custom_response/tutorial006c.py!}
```
### `StreamingResponse`
@@ -226,7 +226,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
✊ 🔁 🚂 ⚖️ 😐 🚂/🎻 &amp; 🎏 📨 💪.
```Python hl_lines="2 14"
{!../../../docs_src/custom_response/tutorial007.py!}
{!../../docs_src/custom_response/tutorial007.py!}
```
#### ⚙️ `StreamingResponse` ⏮️ 📁-💖 🎚
@@ -238,7 +238,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
👉 🔌 📚 🗃 🔗 ⏮️ ☁ 💾, 📹 🏭, &amp; 🎏.
```{ .python .annotate hl_lines="2 10-12 14" }
{!../../../docs_src/custom_response/tutorial008.py!}
{!../../docs_src/custom_response/tutorial008.py!}
```
1⃣. 👉 🚂 🔢. ⚫️ "🚂 🔢" ↩️ ⚫️ 🔌 `yield` 📄 🔘.
@@ -269,13 +269,13 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
📁 📨 🔜 🔌 ☑ `Content-Length`, `Last-Modified` &amp; `ETag` 🎚.
```Python hl_lines="2 10"
{!../../../docs_src/custom_response/tutorial009.py!}
{!../../docs_src/custom_response/tutorial009.py!}
```
👆 💪 ⚙️ `response_class` 🔢:
```Python hl_lines="2 8 10"
{!../../../docs_src/custom_response/tutorial009b.py!}
{!../../docs_src/custom_response/tutorial009b.py!}
```
👉 💼, 👆 💪 📨 📁 ➡ 🔗 ⚪️➡️ 👆 *➡ 🛠️* 🔢.
@@ -291,7 +291,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
👆 💪 ✍ `CustomORJSONResponse`. 👑 👜 👆 ✔️ ✍ `Response.render(content)` 👩‍🔬 👈 📨 🎚 `bytes`:
```Python hl_lines="9-14 17"
{!../../../docs_src/custom_response/tutorial009c.py!}
{!../../docs_src/custom_response/tutorial009c.py!}
```
🔜 ↩️ 🛬:
@@ -319,7 +319,7 @@ FastAPI (🤙 💃) 🔜 🔁 🔌 🎚-📐 🎚. ⚫️ 🔜 🔌 🎚-🆎
🖼 🔛, **FastAPI** 🔜 ⚙️ `ORJSONResponse` 🔢, 🌐 *➡ 🛠️*, ↩️ `JSONResponse`.
```Python hl_lines="2 4"
{!../../../docs_src/custom_response/tutorial010.py!}
{!../../docs_src/custom_response/tutorial010.py!}
```
/// tip

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