Compare commits

..

287 Commits

Author SHA1 Message Date
github-actions[bot] 330f0ba571 📝 Update release notes
[skip ci]
2025-12-17 14:39:37 +00:00
Motov Yurii 06273e48c8
⬆ Bump `markdown-include-variants` from 0.0.7 to 0.0.8 (#14556) 2025-12-17 15:39:10 +01:00
github-actions[bot] a2997a8f7d 📝 Update release notes
[skip ci]
2025-12-17 10:45:18 +00:00
Motov Yurii ed5c5bef5e
🔧 Temporarily disable translations still in progress, being migrated to the new LLM setup (#14555)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-17 11:44:55 +01:00
github-actions[bot] 493ff37fc0 📝 Update release notes
[skip ci]
2025-12-17 10:42:14 +00:00
Sebastián Ramírez 1a1c29e57d
🔧 Add LLM prompt file for French, generated from the existing French docs (#14544) 2025-12-17 11:41:43 +01:00
github-actions[bot] e32eed7599 📝 Update release notes
[skip ci]
2025-12-17 10:17:30 +00:00
Motov Yurii 6400e5ee29
🌐 Sync Portuguese docs (pages found with script) (#14554) 2025-12-17 11:17:03 +01:00
github-actions[bot] d68892ab02 📝 Update release notes
[skip ci]
2025-12-17 10:15:27 +00:00
Motov Yurii 6a8a2d62c4
🌐 Sync Spanish docs (outdated pages found with script) (#14553)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-17 11:15:01 +01:00
github-actions[bot] e675b25c60 📝 Update release notes
[skip ci]
2025-12-17 07:17:24 +00:00
Nils-Hero Lindemann 353b8b29fa
🌐 Sync German docs (#14519)
Sync with #14505 (plus some more)

I actually searched for those patterns in VS Code.

Always:
    files to exclude: README.md, SECURITY.md, llm-prompt.md

This search & replace cleans up the hash parts everywhere under docs/.
It only finds the four occurences in the two _llm-test.md under docs/de/ and docs/pt/

    files to include: docs/**
        Search regex: \{[^\S\n]*#([^\S\n]*[a-z0-9]+(?:-[a-z0-9]+)*)[^\S\n]*\}
        Replace with: { #$1 }

This search finds headings without hash parts. It finds two headings in docs\de\docs\index.md (those which #14505 fixes) and all headings in docs\pt\docs\tutorial\security\index.md, which I also fixed on the way as that document seems to be in sync. docs\pt\docs\index.md is not in Sync, so I didnt touch it.

    files to include: docs/de/**, docs/pt/**
        Search regex: ^(#+)[^\S\n]*([^{}#\s]+(?:[^\S\n]+[^{}\s]+)*)[^\S\n]*(?=\n)
        (added the missing hash parts)
2025-12-17 08:17:04 +01:00
github-actions[bot] 272204c0c7 📝 Update release notes
[skip ci]
2025-12-16 21:05:45 +00:00
Sebastián Ramírez 818ce0fa2f
🔥 Remove inactive/scarce translations to Vietnamese (#14543) 2025-12-16 21:05:18 +00:00
github-actions[bot] ed20bf6bf3 📝 Update release notes
[skip ci]
2025-12-16 20:59:17 +00:00
Sebastián Ramírez 58bc4a15ac
🔥 Remove inactive/scarce translations to Persian (#14542) 2025-12-16 20:58:53 +00:00
github-actions[bot] 9be5063396 📝 Update release notes
[skip ci]
2025-12-16 20:44:35 +00:00
Sebastián Ramírez 4a6a87674a
🔥 Remove translation to emoji to simplify the new setup with LLM autotranslations (#14541) 2025-12-16 21:44:10 +01:00
github-actions[bot] 01bb87275b 📝 Update release notes
[skip ci]
2025-12-16 20:33:42 +00:00
Sebastián Ramírez 9a03503542
🌐 Update translations for pt (update-outdated) (#14537)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-16 21:32:40 +01:00
github-actions[bot] e5d0e78bd4 📝 Update release notes
[skip ci]
2025-12-16 20:32:33 +00:00
Sebastián Ramírez c4fb93f9c2
🔧 Update test workflow config, remove commented code (#14540) 2025-12-16 20:32:09 +00:00
github-actions[bot] 98bee09a6a 📝 Update release notes
[skip ci]
2025-12-16 17:52:40 +00:00
Sebastián Ramírez c68dc2d419
👷 Configure coverage, error on main tests, don't wait for Smokeshow (#14536) 2025-12-16 17:52:17 +00:00
github-actions[bot] ec287a329b 📝 Update release notes
[skip ci]
2025-12-16 17:37:09 +00:00
Sebastián Ramírez c0e4b9cd67
👷 Run Smokeshow always, even on test failures (#14538) 2025-12-16 17:36:42 +00:00
github-actions[bot] c98485514c 📝 Update release notes
[skip ci]
2025-12-16 17:00:34 +00:00
Sebastián Ramírez 6281f8721a
👷 Make Pydantic versions customizable in CI (#14535) 2025-12-16 18:00:12 +01:00
github-actions[bot] 75ad0a0f8c 📝 Update release notes
[skip ci]
2025-12-16 16:34:08 +00:00
Sebastián Ramírez da83d79546
🌐 Update translations for es (update-outdated) (#14532)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-16 17:33:45 +01:00
github-actions[bot] f43cba7e78 📝 Update release notes
[skip ci]
2025-12-16 16:16:56 +00:00
Sebastián Ramírez cbbb11f4df
🌐 Update translations for es (add-missing) (#14533)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-16 16:16:35 +00:00
github-actions[bot] 532ba725a5 📝 Update release notes
[skip ci]
2025-12-16 15:35:03 +00:00
Sebastián Ramírez 886b367a8c
👷 Fix checkout GitHub Action fetch-depth for LLM translations, enable cron monthly (#14531) 2025-12-16 15:34:37 +00:00
github-actions[bot] 41d1b84bd5 📝 Update release notes
[skip ci]
2025-12-16 12:53:54 +00:00
Sebastián Ramírez 5da1cb0792
👷 Fix Typer command for CI LLM translations (#14530) 2025-12-16 12:53:28 +00:00
github-actions[bot] f9397e93b5 📝 Update release notes
[skip ci]
2025-12-16 12:41:12 +00:00
Sebastián Ramírez 2e7aaea524
👷 Update LLM translation CI, add language matrix and extra commands, prepare for scheduled run (#14529) 2025-12-16 12:40:50 +00:00
github-actions[bot] 4414cd849d 📝 Update release notes
[skip ci]
2025-12-16 12:34:25 +00:00
Sebastián Ramírez c548348386
👷 Update github-actions user for GitHub Actions workflows (#14528) 2025-12-16 12:34:01 +00:00
github-actions[bot] 61ffa3eb82 📝 Update release notes
[skip ci]
2025-12-12 16:57:03 +00:00
Sebastián Ramírez 59917ab679
🌐 Remove translations for removed docs (#14516) 2025-12-12 16:56:39 +00:00
github-actions[bot] 1163dbd17f 📝 Update release notes
[skip ci]
2025-12-12 16:54:50 +00:00
Sebastián Ramírez 435d839c72
Add requirements for translations (#14515) 2025-12-12 16:54:13 +00:00
Sebastián Ramírez b1d9769f97 🔖 Release version 0.124.4 2025-12-12 15:59:12 +01:00
github-actions[bot] 89157a803c 📝 Update release notes
[skip ci]
2025-12-12 14:57:20 +00:00
Motov Yurii d86c47477e
🐛 Fix parameter aliases (#14371)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-12 15:56:57 +01:00
Sebastián Ramírez 3fe6522aae 🔖 Release version 0.124.3 2025-12-12 15:32:58 +01:00
github-actions[bot] 80d1f732e5 📝 Update release notes
[skip ci]
2025-12-12 14:31:45 +00:00
Sebastián Ramírez c0556ac3a5
🐛 Fix support for tagged union with discriminator inside of `Annotated` with `Body()` (#14512) 2025-12-12 15:31:21 +01:00
github-actions[bot] 1fcec88ad2 📝 Update release notes
[skip ci]
2025-12-11 21:25:27 +00:00
Motov Yurii f8b216df30
🌐 Sync Russian docs (#14509)
* Translate missing pages

* Update outdated translations
2025-12-11 22:25:03 +01:00
github-actions[bot] 4b905b614c 📝 Update release notes
[skip ci]
2025-12-11 16:16:13 +00:00
Motov Yurii 6c54bcefd3
Add set of tests for request parameters and alias (#14358)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-11 17:15:36 +01:00
github-actions[bot] 475ce41268 📝 Update release notes
[skip ci]
2025-12-11 16:02:50 +00:00
Sebastián Ramírez 564a4ac1b8
👷 Tweak coverage to not pass Smokeshow max file size limit (#14507) 2025-12-11 16:02:26 +00:00
github-actions[bot] 931e80f20c 📝 Update release notes
[skip ci]
2025-12-11 15:28:47 +00:00
Sofie Van Landeghem a7ba9932ba
Expand test matrix to include Windows and MacOS (#14171)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-12-11 16:28:21 +01:00
github-actions[bot] 009c8af7fe 📝 Update release notes
[skip ci]
2025-12-11 14:49:09 +00:00
Sebastián Ramírez 4c4d520198
📝 Tweak links format (#14505) 2025-12-11 14:48:47 +00:00
github-actions[bot] 1cf7cd8af0 📝 Update release notes
[skip ci]
2025-12-10 13:54:57 +00:00
Nils-Hero Lindemann 4a9f13763d
🌐 Sync German docs (#14488)
* Sync with #14472

* Sync with #14413

* Sync with #14486

* Sync with #14487
2025-12-10 14:54:34 +01:00
github-actions[bot] 30747a69c8 📝 Update release notes
[skip ci]
2025-12-10 12:57:18 +00:00
Sebastián Ramírez cd9d093f60
📝 Update docs about re-raising validation errors, do not include string as is to not leak information (#14487) 2025-12-10 12:56:50 +00:00
github-actions[bot] 4a98a66778 📝 Update release notes
[skip ci]
2025-12-10 12:29:04 +00:00
Sebastián Ramírez 442cb306f6
🔥 Remove external links section (#14486) 2025-12-10 12:28:40 +00:00
Sebastián Ramírez 7b0b915749 🔖 Release version 0.124.2 2025-12-10 13:07:53 +01:00
github-actions[bot] 96bdde376f 📝 Update release notes
[skip ci]
2025-12-10 12:06:32 +00:00
Sebastián Ramírez 7ba042e069
🐛 Fix support for `if TYPE_CHECKING`, non-evaluated stringified annotations (#14485) 2025-12-10 13:06:05 +01:00
Sebastián Ramírez 60699f306b 🔖 Release version 0.124.1 2025-12-10 11:38:41 +01:00
github-actions[bot] ae7af59c6d 📝 Update release notes
[skip ci]
2025-12-10 10:36:56 +00:00
Sebastián Ramírez 42b250d14d
🐛 Fix handling arbitrary types when using `arbitrary_types_allowed=True` (#14482) 2025-12-10 11:36:29 +01:00
github-actions[bot] 71a17b5932 📝 Update release notes
[skip ci]
2025-12-10 08:55:57 +00:00
Motov Yurii 9475024640
📝 Add variants for code examples in "Advanced User Guide" (#14413) 2025-12-10 09:55:32 +01:00
github-actions[bot] 5b28a04d55 📝 Update release notes
[skip ci]
2025-12-09 11:12:49 +00:00
Sebastián Ramírez 8cedb742cb
Add test for Pydantic v2, dataclasses, UUID, and `__annotations__` (#14477) 2025-12-09 12:12:24 +01:00
github-actions[bot] 320e7ce8fd 📝 Update release notes
[skip ci]
2025-12-08 13:05:20 +00:00
Alejandra 81517f66cc
📝 Update tech stack in project generation docs (#14472) 2025-12-08 13:04:54 +00:00
Sebastián Ramírez b5ca13249e 🔖 Release version 0.124.0 2025-12-06 14:09:51 +01:00
github-actions[bot] a2cef707e3 📝 Update release notes
[skip ci]
2025-12-06 12:23:23 +00:00
Yuji Teshima 5b6245666b
✏️ Fix typo in `scripts/mkdocs_hooks.py` (#14457) 2025-12-06 13:23:01 +01:00
github-actions[bot] dbd34f1578 📝 Update release notes
[skip ci]
2025-12-06 12:22:24 +00:00
Savannah Ostrowski e1117f7550
🚸 Improve tracebacks by adding endpoint metadata (#14306)
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>
2025-12-06 12:21:57 +00:00
Sebastián Ramírez 08b09e5236 🔖 Release version 0.123.10 2025-12-05 22:26:36 +01:00
github-actions[bot] e7d7038dfa 📝 Update release notes
[skip ci]
2025-12-05 21:21:29 +00:00
Motov Yurii da0ffab0b2
🐛 Fix using class (not instance) dependency that has `__call__` method (#14458)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-05 21:21:05 +00:00
github-actions[bot] 516169428d 📝 Update release notes
[skip ci]
2025-12-05 20:19:54 +00:00
Motov Yurii 812a1926f0
🐛 Fix `separate_input_output_schemas=False` with `computed_field` (#14453) 2025-12-05 21:19:30 +01:00
Sebastián Ramírez f0dd1046a6 🔖 Release version 0.123.9 2025-12-04 23:23:21 +01:00
github-actions[bot] 188d631011 📝 Update release notes
[skip ci]
2025-12-04 22:22:25 +00:00
Sebastián Ramírez 0b5fa563cd
🐛 Fix OAuth2 scopes in OpenAPI in extra corner cases, parent dependency with scopes, sub-dependency security scheme without scopes (#14459) 2025-12-04 23:22:01 +01:00
Sebastián Ramírez eb1d50479b 🔖 Release version 0.123.8 2025-12-04 14:01:00 +01:00
github-actions[bot] e248a4d22b 📝 Update release notes
[skip ci]
2025-12-04 12:59:45 +00:00
Sebastián Ramírez 0ec4bafca2
🐛 Fix OpenAPI security scheme OAuth2 scopes declaration, deduplicate security schemes with different scopes (#14455) 2025-12-04 13:59:24 +01:00
Sebastián Ramírez 603df6e36f 🔖 Release version 0.123.7 2025-12-04 09:27:38 +01:00
github-actions[bot] 6c565482cf 📝 Update release notes
[skip ci]
2025-12-04 08:18:55 +00:00
chaen 861598b4e3
🐛 Fix evaluating stringified annotations in Python 3.10 (#11355)
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-04 09:18:32 +01:00
Sebastián Ramírez 811fa89875 🔖 Release version 0.123.6 2025-12-04 08:33:11 +01:00
github-actions[bot] 6c6b9d7a2b 📝 Update release notes
[skip ci]
2025-12-04 07:29:53 +00:00
Sebastián Ramírez bba4d4c95e
🐛 Fix support for functools wraps and partial combined, for async and regular functions and classes in path operations and dependencies (#14448)
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
2025-12-04 08:29:28 +01:00
Sebastián Ramírez c57ac7bdf3 🔖 Release version 0.123.5 2025-12-02 22:06:25 +01:00
github-actions[bot] 3c440c762a 📝 Update release notes
[skip ci]
2025-12-02 20:58:53 +00:00
Lie Ryan 9824486616
Allow using dependables with `functools.partial()` (#9753)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 20:58:30 +00:00
github-actions[bot] aee8e78078 📝 Update release notes
[skip ci]
2025-12-02 17:33:22 +00:00
Nils-Hero Lindemann f4a17b7568
🌐 Sync German docs (#14367)
* Sync with #14217

* Sync with #14359

* Sync with #13786

* Sync with #14070

* Sync with #14120

* Sync with #14211

* Sync with #14405

* "to deploy" -> "deployen"

The LLM used that translation a lot ithis convinced me that "deployen" it is the better word. "bereitstellen" (or "ausliefern") is still used for "to serve".

---------

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
2025-12-02 18:32:56 +01:00
github-actions[bot] 4ade6d62e2 📝 Update release notes
[skip ci]
2025-12-02 17:23:36 +00:00
[object Object] 1c1e584abd
Add support for wrapped functions (e.g. `@functools.wraps()`) used with forward references (#5077)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 18:23:14 +01:00
github-actions[bot] 930b27e5fa 📝 Update release notes
[skip ci]
2025-12-02 17:00:02 +00:00
Victorien 80d69ae0bb
🐛 Fix optional sequence handling with new union syntax from Python 3.10 (#14430)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 16:59:38 +00:00
github-actions[bot] cff2236dac 📝 Update release notes
[skip ci]
2025-12-02 16:49:12 +00:00
Sebastián Ramírez a79ae3d66f
🔥 Remove dangling extra condiitonal no longer needed (#14435) 2025-12-02 16:48:46 +00:00
github-actions[bot] f636513390 📝 Update release notes
[skip ci]
2025-12-02 13:43:52 +00:00
Sebastián Ramírez 247ef32e79
♻️ Refactor internals, update `is_coroutine` check to reuse internal supported variants (unwrap, check class) (#14434) 2025-12-02 13:43:31 +00:00
github-actions[bot] 13a98c9988 📝 Update release notes
[skip ci]
2025-12-02 13:34:45 +00:00
Matthew Martin 73c411e1b9
Handle wrapped dependencies (#9555)
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 14:34:19 +01:00
Sebastián Ramírez 4976568fc7 🔖 Release version 0.123.4 2025-12-02 11:47:05 +01:00
github-actions[bot] fb30cc2f50 📝 Update release notes
[skip ci]
2025-12-02 09:22:35 +00:00
Vincent Grafé f95a174288
🐛 Fix OpenAPI schema support for computed fields when using `separate_input_output_schemas=False` (#13207)
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: svlandeg <sofie.vanlandeghem@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 09:22:08 +00:00
github-actions[bot] 5126e099bd 📝 Update release notes
[skip ci]
2025-12-02 09:11:52 +00:00
Motov Yurii dcf0299195
📝 Fix docstring of `servers` parameter (#14405)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 09:11:29 +00:00
Sebastián Ramírez c516c9904b 🔖 Release version 0.123.3 2025-12-02 08:42:22 +01:00
github-actions[bot] b49c05ec22 📝 Update release notes
[skip ci]
2025-12-02 07:24:31 +00:00
Motov Yurii 015b4fae9c
🐛 Fix Query\Header\Cookie parameter model alias (#14360)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 07:24:09 +00:00
github-actions[bot] eead41bf4c 📝 Update release notes
[skip ci]
2025-12-02 07:10:50 +00:00
Motov Yurii 0f613d9051
🐛 Fix optional sequence handling in `serialize sequence value` with Pydantic V2 (#14297)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 08:10:27 +01:00
Sebastián Ramírez 3c54a8f07b 🔖 Release version 0.123.2 2025-12-02 06:31:27 +01:00
github-actions[bot] e1a2933739 📝 Update release notes
[skip ci]
2025-12-02 05:09:48 +00:00
zadevhub 00b97526e7
📝 Add tip on how to install `pip` in case of `No module named pip` error in `virtual-environments.md` (#14211) 2025-12-02 06:09:25 +01:00
github-actions[bot] 2ca7709c24 📝 Update release notes
[skip ci]
2025-12-02 05:07:29 +00:00
Flavius bb05007f55
📝 Update Primary Key notes for the SQL databases tutorial to avoid confusion (#14120) 2025-12-02 06:06:56 +01:00
github-actions[bot] 0f7ce0b78a 📝 Update release notes
[skip ci]
2025-12-02 05:04:09 +00:00
SaisakthiM cdafd64c15
📝 Clarify estimation note in documentation (#14070) 2025-12-02 06:03:46 +01:00
github-actions[bot] c6c7b72096 📝 Update release notes
[skip ci]
2025-12-02 05:01:37 +00:00
Alex Colby cb3792d39e
🐛 Fix unformatted `{type_}` in FastAPIError (#14416)
Co-authored-by: Alex Colby <alex.colby@intellisense.io>
2025-12-02 06:01:11 +01:00
github-actions[bot] 10eed3806a 📝 Update release notes
[skip ci]
2025-12-02 04:57:45 +00:00
Motov Yurii de5bec637c
🐛 Fix parsing extra non-body parameter list (#14356)
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>
2025-12-02 05:57:19 +01:00
github-actions[bot] 2330e2de75 📝 Update release notes
[skip ci]
2025-12-02 04:49:52 +00:00
Motov Yurii 6cf40df24d
🐛 Fix parsing extra `Form` parameter list (#14303)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 05:49:32 +01:00
github-actions[bot] 740ec2787b 📝 Update release notes
[skip ci]
2025-12-02 04:40:16 +00:00
ad hoc d68c066246
🐛 Fix support for form values with empty strings interpreted as missing (`None` if that's the default), for compatibility with HTML forms (#13537)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 05:39:55 +01:00
Sebastián Ramírez c3373205d0 🔖 Release version 0.123.1 2025-12-02 05:30:18 +01:00
github-actions[bot] 3b4b5ab8c8 📝 Update release notes
[skip ci]
2025-12-02 04:04:37 +00:00
Sofie Van Landeghem 8f99a2b734
🐛 Avoid accessing non-existing "$ref" key for Pydantic v2 compat remapping (#14361)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-02 05:04:13 +01:00
github-actions[bot] 74b4c3c9a1 📝 Update release notes
[skip ci]
2025-12-02 04:03:00 +00:00
Hemanth U bf322d0e94
🐛 Fix Windows UnicodeEncodeError in CLI test (#14295)
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-12-02 04:02:38 +00:00
github-actions[bot] 327bad18aa 📝 Update release notes
[skip ci]
2025-12-02 03:32:40 +00:00
Kent Huang 20f40b29c0
🐛 Fix `TypeError` when encoding a decimal with a `NaN` or `Infinity` value (#12935)
Signed-off-by: Kent Huang <kent@infuseai.io>
2025-12-02 04:31:59 +01:00
github-actions[bot] ee490906d8 📝 Update release notes
[skip ci]
2025-12-01 20:07:18 +00:00
Sebastián Ramírez 6e82df816d
🔧 Update sponsors: add Greptile (#14429) 2025-12-01 21:06:57 +01:00
github-actions[bot] e752224bce 📝 Update release notes
[skip ci]
2025-12-01 13:17:51 +00:00
Sebastián Ramírez 0dee714026
👥 Update FastAPI GitHub topic repositories (#14426)
Co-authored-by: github-actions <github-actions@github.com>
2025-12-01 14:17:29 +01:00
github-actions[bot] 938f471079 📝 Update release notes
[skip ci]
2025-12-01 06:33:00 +00:00
Motov Yurii 6400d8a623
⬆ Bump markdown-include-variants from 0.0.6 to 0.0.7 (#14423) 2025-12-01 07:32:32 +01:00
github-actions[bot] f8e46d98a0 📝 Update release notes
[skip ci]
2025-12-01 06:31:20 +00:00
Sebastián Ramírez 8a7ad3d255
👥 Update FastAPI People - Sponsors (#14422)
Co-authored-by: github-actions <github-actions@github.com>
2025-12-01 07:30:56 +01:00
github-actions[bot] d661bb1324 📝 Update release notes
[skip ci]
2025-12-01 06:28:06 +00:00
Sebastián Ramírez 32aba57b49
👥 Update FastAPI People - Contributors and Translators (#14420)
Co-authored-by: github-actions <github-actions@github.com>
2025-12-01 07:27:43 +01:00
Sebastián Ramírez f2bab95267 🔖 Release version 0.123.0 2025-11-30 15:47:35 +01:00
github-actions[bot] c38e3e0108 📝 Update release notes
[skip ci]
2025-11-30 14:46:13 +00:00
Sebastián Ramírez 7fbd30460f
🐛 Cache dependencies that don't use scopes and don't have sub-dependencies with scopes (#14419)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-11-30 15:45:49 +01:00
Sebastián Ramírez 63d7a2b997 🔖 Release version 0.122.1 2025-11-30 13:00:20 +01:00
github-actions[bot] 7681f2904d 📝 Update release notes
[skip ci]
2025-11-30 11:57:24 +00:00
Kristján Valur Jónsson 378ad688b7
🐛 Fix hierarchical security scope propagation (#5624)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com>
Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2025-11-30 12:57:01 +01:00
github-actions[bot] c6487ed632 📝 Update release notes
[skip ci]
2025-11-29 12:09:26 +00:00
Motov Yurii 62a6974004
⬆ Bump markdown-include-variants from 0.0.5 to 0.0.6 (#14418) 2025-11-29 13:08:57 +01:00
github-actions[bot] 998288261a 📝 Update release notes
[skip ci]
2025-11-28 15:55:40 +00:00
Sebastián Ramírez 8ab7167eaf
💅 Update CSS to explicitly use emoji font (#14415) 2025-11-28 15:55:15 +00:00
Sebastián Ramírez 5b0625df96 🔖 Release version 0.122.0 2025-11-24 20:14:34 +01:00
Sebastián Ramírez 8732c53478 📝 Updates release notes 2025-11-24 20:12:28 +01:00
github-actions[bot] a4ef97afd9 📝 Update release notes
[skip ci]
2025-11-24 19:03:33 +00:00
Motov Yurii 51ad909ffe
🐛 Use `401` status code in security classes when credentials are missing (#13786)
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>
2025-11-24 20:03:06 +01:00
github-actions[bot] e2354a0a06 📝 Update release notes
[skip ci]
2025-11-24 15:00:36 +00:00
github-actions[bot] cc66dee55c 📝 Update release notes
[skip ci]
2025-11-24 15:00:29 +00:00
github-actions[bot] ecfb752487 📝 Update release notes
[skip ci]
2025-11-24 15:00:13 +00:00
github-actions[bot] 8b18522205 📝 Update release notes
[skip ci]
2025-11-24 15:00:12 +00:00
github-actions[bot] a2395e0243 📝 Update release notes
[skip ci]
2025-11-24 14:59:55 +00:00
github-actions[bot] c7d05a903c 📝 Update release notes
[skip ci]
2025-11-24 14:58:56 +00:00
Sofie Van Landeghem ab33b45718
👷 Upgrade `latest-changes` GitHub Action and pin `actions/checkout@v5` (#14403)
👷 Upgrade latest-changes and pin actions/checkout@v5
2025-11-24 15:58:32 +01:00
Motov Yurii 5265c4f5cb
🔧 Configure labeler to exclude files that start from underscore for `lang-all` label (#14213) 2025-11-23 21:10:04 +01:00
Sebastián Ramírez 4f3ff79736
👷 Add pre-commit config with local script for permalinks (#14398)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-11-23 18:41:43 +01:00
Sebastián Ramírez 79bc4b9ca0
👷 Add custom pre-commit CI (#14397) 2025-11-23 17:36:34 +01:00
Sebastián Ramírez ae951f6981
💄 Use font Fira Code to fix display of Rich panels in docs in Windows (#14387) 2025-11-23 10:27:40 +01:00
dependabot[bot] cbe5bdb85f
⬆ Bump actions/checkout from 5 to 6 (#14381)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-21 14:03:21 +01:00
github-actions[bot] 2909f8a628 📝 Update release notes
[skip ci]
2025-11-21 12:49:34 +00:00
Motov Yurii 32b375c5e4
🛠️ Add `add-permalinks` and `add-permalinks-page` to `scripts/docs.py` (#14033)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-11-21 13:49:11 +01:00
github-actions[bot] 456008a52b 📝 Update release notes
[skip ci]
2025-11-20 10:45:39 +00:00
Sebastián Ramírez be5a6311f5
🔧 Upgrade Material for MkDocs and remove insiders (#14375) 2025-11-20 11:45:16 +01:00
Sebastián Ramírez 325fd16d32 🔖 Release version 0.121.3 2025-11-19 17:51:59 +01:00
github-actions[bot] 7659b70da0 📝 Update release notes
[skip ci]
2025-11-19 16:50:42 +00:00
Sebastián Ramírez 85701631a0
♻️ Make the result of `Depends()` and `Security()` hashable, as a workaround for other tools interacting with these internal parts (#14372) 2025-11-19 17:50:18 +01:00
github-actions[bot] 566e3157a5 📝 Update release notes
[skip ci]
2025-11-19 11:55:32 +00:00
Ben Beasley 569226e753
⬆️ Bump Starlette to <`0.51.0` (#14282) 2025-11-19 12:55:05 +01:00
github-actions[bot] 33a75f4817 📝 Update release notes
[skip ci]
2025-11-19 10:12:24 +00:00
Nils-Hero Lindemann 89baa704a9
📝 Add missing hash part (#14369)
Add missing hash part

Was forgotten in #14359. I already added it in #14367
2025-11-19 11:12:00 +01:00
github-actions[bot] 827ed1e6a2 📝 Update release notes
[skip ci]
2025-11-18 08:30:46 +00:00
Edge-Seven df83eb7278
📝 Fix typos in code comments (#14364)
Fix typos in some files

Co-authored-by: khanhkhanhlele <namkhanh20xx@gmail.com>
2025-11-18 09:30:20 +01:00
github-actions[bot] 4e84f31694 📝 Update release notes
[skip ci]
2025-11-17 19:34:16 +00:00
Sebastián Ramírez 994d6cc912
📝 Add docs for using FastAPI Cloud (#14359) 2025-11-17 20:33:53 +01:00
Sebastián Ramírez 02e108d166 🔖 Release version 0.121.2 2025-11-13 18:03:55 +01:00
github-actions[bot] d3b75974f4 📝 Update release notes
[skip ci]
2025-11-13 13:59:34 +00:00
Sebastián Ramírez 5d40dfbc9b
🐛 Fix handling of JSON Schema attributes named "$ref" (#14349) 2025-11-13 14:59:07 +01:00
github-actions[bot] eaf611f9ee 📝 Update release notes
[skip ci]
2025-11-13 09:22:06 +00:00
Mia Bajić 004ab1a9d1
📝 Add EuroPython talk & podcast episode with Sebastián Ramírez (#14260)
Add EuroPython & podcast episode with Sebastián Ramírez
2025-11-13 10:21:43 +01:00
github-actions[bot] d1be85c728 📝 Update release notes
[skip ci]
2025-11-13 07:37:43 +00:00
Motov Yurii 42930fe600
✏️ Fix links and add missing permalink in docs (#14217)
* Fix link url to match link text

* Add missing permalink in `behind-a-proxy.md`

* Fix link in `advanced-dependencies.md`
2025-11-13 08:37:15 +01:00
github-actions[bot] 9e362d9f6e 📝 Update release notes
[skip ci]
2025-11-12 16:24:24 +00:00
Rafael de Oliveira Marques 540a83da65
🌐 Update Portuguese translations with LLM prompt (#14228)
* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* validated llm translation

* fix non-Annotated in llm-prompt

* rerun after a few changes in llm-prompt

* fix non-Annotated

* validated llm translation

* fix llm translation

* update outdated translations

* fix translation for operation IDs

* add header link

* add missing link

* fix line break

* fix diff

* fix llm translation

* fix 'Atualize' to 'Atualizar'

* update alternatives.md

* update async.md

* update fastapi-cli.md

* update features.md

* update help-fastapi.md

* update history-design-future.md

* update index.md

* update advanced/events.md

* update advanced/middleware.md

* update advanced/response-cookies.md

* update advanced/response-headers.md

* update advanced/templates.md

* update advanced/testing-websockets.md

* update advanced/using-request-directly.md

* update advanced/websockets.md

* update advanced/security/oauth2-scopes.md

* update deployment/cloud.md

* update deployment/manually.md

* update how-to/custom-request-and-route.md

* update how-to/migrate-from-pydantic-v1-to-pydantic-v2.md

* update tutorial/background-tasks.md

* update tutorial/first-steps.md

* update tutorial/handling-errors.md

* update tutorial/middleware.md

* update tutorial/request-files.md

* update tutorial/sql-databases.md

* update tutorial/static-files.md

* update tutorial/testing.md

* update tutorial/dependencies/dependencies-with-yield.md

* update advanced/advanced-dependencies.md

---------

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
2025-11-12 17:23:57 +01:00
github-actions[bot] 1a2e4152ed 📝 Update release notes
[skip ci]
2025-11-12 15:23:24 +00:00
Rafael de Oliveira Marques 0878361f6b
🔨 Add Portuguese translations LLM prompt (#14208)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-11-12 16:22:59 +01:00
github-actions[bot] 6fae64ff49 📝 Update release notes
[skip ci]
2025-11-10 20:55:20 +00:00
Motov Yurii c09ba719ba
🌐 Sync Russian docs (#14331)
Update outdated\missing pages in Rus translations
2025-11-10 21:54:56 +01:00
github-actions[bot] 409e7b503c 📝 Update release notes
[skip ci]
2025-11-10 08:34:48 +00:00
Nils-Hero Lindemann db488f3220
🌐 Sync German docs (#14317)
* Sync with #14262

* Sync with #14287

* Two improvements

* "Frühzeitig beenden" -> "Frühes Beenden"
* "Make herum" bold too
2025-11-10 09:34:25 +01:00
Sebastián Ramírez 1c7e2540c2 🔖 Release version 0.121.1 2025-11-08 22:47:00 +01:00
github-actions[bot] 9e5439959a 📝 Update release notes
[skip ci]
2025-11-08 21:43:59 +00:00
luzzodev 282f372eda
🐛 Fix `Depends(func, scope='function')` for top level (parameterless) dependencies (#14301) 2025-11-08 22:43:30 +01:00
github-actions[bot] 972a967d5d 📝 Update release notes
[skip ci]
2025-11-04 08:39:30 +00:00
github-actions[bot] 4170f621a5 📝 Update release notes
[skip ci]
2025-11-04 08:38:34 +00:00
dependabot[bot] 67c8dfaf0f
⬆ Bump ruff from 0.13.2 to 0.14.3 (#14276)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.13.2 to 0.14.3.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/0.13.2...0.14.3)

---
updated-dependencies:
- dependency-name: ruff
  dependency-version: 0.14.3
  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>
2025-11-04 09:38:16 +01:00
pre-commit-ci[bot] 34db1e2e2c
⬆ [pre-commit.ci] pre-commit autoupdate (#14289)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.14.2 → v0.14.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.2...v0.14.3)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-11-04 09:38:05 +01:00
github-actions[bot] b787103226 📝 Update release notes
[skip ci]
2025-11-03 13:20:34 +00:00
Sebastián Ramírez 289b4aa2fa
📝 Upate docs for advanced dependencies with `yield`, noting the changes in 0.121.0, adding `scope` (#14287) 2025-11-03 14:19:58 +01:00
Sebastián Ramírez 4efae81a76 🔖 Release version 0.121.0 2025-11-03 11:21:36 +01:00
Sebastián Ramírez 3690140555 📝 Update release notes 2025-11-03 11:19:56 +01:00
github-actions[bot] ad4d8f24ca 📝 Update release notes
[skip ci]
2025-11-03 10:13:13 +00:00
Sebastián Ramírez ac438b9934
Add support for dependencies with scopes, support `scope="request"` for dependencies with `yield` that exit before the response is sent (#14262)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-11-03 11:12:49 +01:00
github-actions[bot] 425a4c5bb1 📝 Update release notes
[skip ci]
2025-11-03 09:25:02 +00:00
github-actions[bot] 3a223b9073 📝 Update release notes
[skip ci]
2025-11-03 09:24:57 +00:00
Sebastián Ramírez 566e0d60b2
👥 Update FastAPI People - Contributors and Translators (#14273)
Co-authored-by: github-actions <github-actions@github.com>
2025-11-03 10:24:36 +01:00
github-actions[bot] 940ee0c9c3 📝 Update release notes
[skip ci]
2025-11-03 09:24:17 +00:00
Sebastián Ramírez f8df43d734
👥 Update FastAPI People - Sponsors (#14274)
Co-authored-by: github-actions <github-actions@github.com>
2025-11-03 10:24:09 +01:00
Sebastián Ramírez dbb7020a4d
👥 Update FastAPI GitHub topic repositories (#14280)
Co-authored-by: github-actions <github-actions@github.com>
2025-11-03 10:23:52 +01:00
github-actions[bot] 32da8ca78b 📝 Update release notes
[skip ci]
2025-11-02 17:15:57 +00:00
dependabot[bot] 8c42d0ce16
⬆ Bump mkdocs-macros-plugin from 1.4.0 to 1.4.1 (#14277)
Bumps [mkdocs-macros-plugin](https://github.com/fralau/mkdocs_macros_plugin) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/fralau/mkdocs_macros_plugin/releases)
- [Changelog](https://github.com/fralau/mkdocs-macros-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fralau/mkdocs_macros_plugin/compare/v1.4.0...v1.4.1)

---
updated-dependencies:
- dependency-name: mkdocs-macros-plugin
  dependency-version: 1.4.1
  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>
2025-11-02 18:15:19 +01:00
github-actions[bot] 2a25f6d3a3 📝 Update release notes
[skip ci]
2025-11-02 17:15:00 +00:00
dependabot[bot] 8be5867de7
⬆ Bump mkdocstrings[python] from 0.26.1 to 0.30.1 (#14279)
Bumps [mkdocstrings[python]](https://github.com/mkdocstrings/mkdocstrings) from 0.26.1 to 0.30.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.26.1...0.30.1)

---
updated-dependencies:
- dependency-name: mkdocstrings[python]
  dependency-version: 0.30.1
  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>
2025-11-02 18:14:31 +01:00
Sebastián Ramírez fad35ef43f 🔖 Release version 0.120.4 2025-10-31 19:35:33 +01:00
github-actions[bot] 4d57c13055 📝 Update release notes
[skip ci]
2025-10-31 18:35:03 +00:00
Motov Yurii 496de1816a
🐛 Fix security schemes in OpenAPI when added at the top level app (#14266)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2025-10-31 19:34:30 +01:00
Sebastián Ramírez 2cf04ee30d 🔖 Release version 0.120.3 2025-10-30 21:40:08 +01:00
github-actions[bot] ec00f5a90f 📝 Update release notes
[skip ci]
2025-10-30 19:51:03 +00:00
Motov Yurii 8b46d8821b
📝 Update note for untranslated pages (#14257)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-30 20:50:37 +01:00
github-actions[bot] 17fcbbe910 📝 Update release notes
[skip ci]
2025-10-30 19:35:31 +00:00
Sebastián Ramírez dcfb8b9dda
♻️ Reduce internal cyclic recursion in dependencies, from 2 functions calling each other to 1 calling itself (#14256) 2025-10-30 20:35:04 +01:00
github-actions[bot] 1fc586c3a5 📝 Update release notes
[skip ci]
2025-10-30 04:59:14 +00:00
Sebastián Ramírez bb88a0f94a
♻️ Refactor internals of dependencies, simplify code and remove `get_param_sub_dependant` (#14255) 2025-10-30 05:58:49 +01:00
github-actions[bot] 9d1a384f4f 📝 Update release notes
[skip ci]
2025-10-30 04:52:12 +00:00
Sebastián Ramírez c144f9fbd3
♻️ Refactor internals of dependencies, simplify using dataclasses (#14254) 2025-10-30 05:51:50 +01:00
Sebastián Ramírez 22ccca21fc 🔖 Release version 0.120.2 2025-10-29 14:44:41 +01:00
github-actions[bot] d2a703d5cc 📝 Update release notes
[skip ci]
2025-10-29 13:43:35 +00:00
Sebastián Ramírez 35aa12b9bd
🔧 Add sponsor: SerpApi (#14248) 2025-10-29 14:43:11 +01:00
github-actions[bot] c01b5dd96f 📝 Update release notes
[skip ci]
2025-10-29 13:09:57 +00:00
Sebastián Ramírez 6a657f360d
🐛 Fix separation of schemas with nested models introduced in 0.119.0 (#14246) 2025-10-29 14:09:30 +01:00
github-actions[bot] 7132a69046 📝 Update release notes
[skip ci]
2025-10-28 07:50:28 +00:00
github-actions[bot] db7feb5a3e 📝 Update release notes
[skip ci]
2025-10-28 07:50:26 +00:00
github-actions[bot] 448ea5ec82 📝 Update release notes
[skip ci]
2025-10-28 07:48:51 +00:00
pre-commit-ci[bot] b618e0f9d4
⬆ [pre-commit.ci] pre-commit autoupdate (#14237)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.14.1 → v0.14.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.1...v0.14.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-28 08:48:46 +01:00
dependabot[bot] ccf50ca477
⬆ Bump actions/download-artifact from 5 to 6 (#14236)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-28 08:48:36 +01:00
dependabot[bot] a0ef245067
⬆ Bump actions/upload-artifact from 4 to 5 (#14235)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-28 08:48:28 +01:00
Sebastián Ramírez 78c94c3f56 🔖 Release version 0.120.1 2025-10-27 18:51:46 +01:00
github-actions[bot] 4b0301b280 📝 Update release notes
[skip ci]
2025-10-27 17:50:15 +00:00
Motov Yurii 436932aef5
⬆️ Bump Starlette to <`0.50.0` (#14234) 2025-10-27 18:49:54 +01:00
github-actions[bot] 3ea6a4a0b1 📝 Update release notes
[skip ci]
2025-10-27 14:47:51 +00:00
Motov Yurii 96dd32718b
🔧 Add `license` and `license-files` to `pyproject.toml`, remove `License` from `classifiers` (#14230) 2025-10-27 15:45:14 +01:00
Sebastián Ramírez cd40c5b40f 🔖 Release version 0.120.0 2025-10-23 22:54:45 +02:00
Sebastián Ramírez 1c6ee57bbf 📝 Update release notes 2025-10-23 22:54:19 +02:00
github-actions[bot] 09f40968cb 📝 Update release notes
[skip ci]
2025-10-23 20:32:06 +00:00
Sebastián Ramírez d390f2e41f
Migrate internal reference documentation from `typing_extensions.Doc` to `annotated_doc.Doc` (#14222) 2025-10-23 22:31:35 +02:00
github-actions[bot] cb7018d782 📝 Update release notes
[skip ci]
2025-10-21 20:32:57 +00:00
Nils-Hero Lindemann a578ea1fd3
🛠️ Update German LLM prompt and test file (#14189)
Minor fixes in German LLM prompt and test file

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
2025-10-21 22:32:28 +02:00
github-actions[bot] 9c912d1dd6 📝 Update release notes
[skip ci]
2025-10-21 07:53:59 +00:00
pre-commit-ci[bot] da011f212a
⬆ [pre-commit.ci] pre-commit autoupdate (#14181)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.13.3 → v0.14.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.13.3...v0.14.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-21 09:53:27 +02:00
github-actions[bot] 046d49b5a9 📝 Update release notes
[skip ci]
2025-10-20 14:00:33 +00:00
Nils-Hero Lindemann 847280450a
🌐 Sync German docs (#14188)
Sync German docs with #14168

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
2025-10-20 16:00:08 +02:00
Sebastián Ramírez 864b569cf8 🔖 Release version 0.119.1 2025-10-20 13:28:38 +02:00
github-actions[bot] 43f15d3b43 📝 Update release notes
[skip ci]
2025-10-20 11:27:39 +00:00
Sofie Van Landeghem d8c691f7f0
🐛 Fix internal Pydantic v1 compatibility (warnings) for Python 3.14 and Pydantic 2.12.1 (#14186)
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>
2025-10-20 13:26:49 +02:00
github-actions[bot] 6e49dc0295 📝 Update release notes
[skip ci]
2025-10-19 19:12:47 +00:00
Sebastián Ramírez 7df594d284
🔧 Add sponsor Requestly (#14205) 2025-10-19 21:12:22 +02:00
github-actions[bot] 81f85831f5 📝 Update release notes
[skip ci]
2025-10-11 19:36:56 +00:00
Motov Yurii 7f810ca93b
🔧 Configure reminder for `waiting` label in `issue-manager` (#14156) 2025-10-11 21:36:25 +02:00
github-actions[bot] 414f961f1f 📝 Update release notes
[skip ci]
2025-10-11 17:49:15 +00:00
Marcelo Trylesinski dde7bd1ceb
📝 Replace `starlette.io` by `starlette.dev` and `uvicorn.org` by `uvicorn.dev` (#14176)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-11 17:48:49 +00:00
Sebastián Ramírez 2e721e1b02 🔖 Release version 0.119.0 2025-10-11 19:09:01 +02:00
Sebastián Ramírez fc7a0686af 📝 Update release notes 2025-10-11 19:07:40 +02:00
github-actions[bot] 3a3879b2c3 📝 Update release notes
[skip ci]
2025-10-11 16:46:19 +00:00
Sebastián Ramírez d34918abf0
Add support for `from pydantic.v1 import BaseModel`, mixed Pydantic v1 and v2 models in the same app (#14168)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-11 18:45:54 +02:00
837 changed files with 36011 additions and 29069 deletions

1
.github/labeler.yml vendored
View File

@ -17,6 +17,7 @@ lang-all:
- docs/*/docs/**
- all-globs-to-all-files:
- '!docs/en/docs/**'
- '!docs/*/**/_*.md'
- '!fastapi/**'
- '!pyproject.toml'

View File

@ -21,7 +21,7 @@ jobs:
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
# For pull requests it's not necessary to checkout the code but for the main branch it is
- uses: dorny/paths-filter@v3
id: filter
@ -32,12 +32,9 @@ jobs:
- docs/**
- docs_src/**
- requirements-docs.txt
- requirements-docs-insiders.txt
- pyproject.toml
- mkdocs.yml
- mkdocs.insiders.yml
- mkdocs.maybe-insiders.yml
- mkdocs.no-insiders.yml
- mkdocs.env.yml
- .github/workflows/build-docs.yml
- .github/workflows/deploy-docs.yml
- scripts/mkdocs_hooks.py
@ -48,7 +45,7 @@ jobs:
outputs:
langs: ${{ steps.show-langs.outputs.langs }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
@ -63,12 +60,6 @@ jobs:
pyproject.toml
- name: Install docs extras
run: uv pip install -r requirements-docs.txt
# Install MkDocs Material Insiders here just to put it in the cache for the rest of the steps
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
run: uv pip install -r requirements-docs-insiders.txt
env:
TOKEN: ${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}
- name: Verify Docs
run: python ./scripts/docs.py verify-docs
- name: Export Language Codes
@ -90,7 +81,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
@ -105,11 +96,6 @@ jobs:
pyproject.toml
- name: Install docs extras
run: uv pip install -r requirements-docs.txt
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
run: uv pip install -r requirements-docs-insiders.txt
env:
TOKEN: ${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}
- name: Update Languages
run: python ./scripts/docs.py update-languages
- uses: actions/cache@v4
@ -118,7 +104,7 @@ jobs:
path: docs/${{ matrix.lang }}/.cache
- name: Build Docs
run: python ./scripts/docs.py build-lang ${{ matrix.lang }}
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v5
with:
name: docs-site-${{ matrix.lang }}
path: ./site/**

View File

@ -24,7 +24,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -23,7 +23,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
@ -49,7 +49,7 @@ jobs:
run: |
rm -rf ./site
mkdir ./site
- uses: actions/download-artifact@v5
- uses: actions/download-artifact@v6
with:
path: ./site/
pattern: docs-site-*

View File

@ -38,7 +38,11 @@ jobs:
},
"waiting": {
"delay": 2628000,
"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."
"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.",
"reminder": {
"before": "P3D",
"message": "Heads-up: this will be closed in 3 days unless theres new activity."
}
},
"invalid": {
"delay": 0,

View File

@ -20,7 +20,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -24,6 +24,8 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
# pin to actions/checkout@v5 for compatibility with latest-changes
# Ref: https://github.com/actions/checkout/issues/2313
- uses: actions/checkout@v5
with:
# To allow latest-changes to commit to the main branch
@ -34,7 +36,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- uses: tiangolo/latest-changes@0.4.0
- uses: tiangolo/latest-changes@0.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest_changes_file: docs/en/docs/release-notes.md

View File

@ -28,7 +28,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -24,7 +24,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

88
.github/workflows/pre-commit.yml vendored Normal file
View File

@ -0,0 +1,88 @@
name: pre-commit
on:
pull_request:
types:
- opened
- synchronize
env:
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
name: Checkout PR for own repo
if: env.IS_FORK == 'false'
with:
# To be able to commit it needs more than the last commit
ref: ${{ github.head_ref }}
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
token: ${{ secrets.PRE_COMMIT }}
# pre-commit lite ci needs the default checkout configs to work
- uses: actions/checkout@v5
name: Checkout PR for fork
if: env.IS_FORK == 'true'
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: |
requirements**.txt
pyproject.toml
uv.lock
- name: Install Dependencies
run: |
uv venv
uv pip install -r requirements.txt
- name: Run pre-commit
id: precommit
run: |
# Fetch the base branch for comparison
git fetch origin ${{ github.base_ref }}
uvx pre-commit run --from-ref origin/${{ github.base_ref }} --to-ref HEAD --show-diff-on-failure
continue-on-error: true
- name: Commit and push changes
if: env.IS_FORK == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "🎨 Auto format"
git push
fi
- uses: pre-commit-ci/lite-action@v1.1.0
if: env.IS_FORK == 'true'
with:
msg: 🎨 Auto format
- name: Error out on pre-commit errors
if: steps.precommit.outcome == 'failure'
run: exit 1
# https://github.com/marketplace/actions/alls-green#why
pre-commit-alls-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- pre-commit
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

View File

@ -20,7 +20,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -13,7 +13,6 @@ env:
jobs:
smokeshow:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
@ -21,20 +20,18 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.9'
python-version: '3.13'
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- run: uv pip install -r requirements-github-actions.txt
- uses: actions/download-artifact@v5
- uses: actions/download-artifact@v6
with:
name: coverage-html
path: htmlcov

View File

@ -24,7 +24,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -22,7 +22,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -23,7 +23,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
@ -31,41 +31,60 @@ jobs:
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- name: Install Dependencies
run: uv pip install -r requirements-tests.txt
- name: Install Pydantic v2
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
- name: Lint
run: bash scripts/lint.sh
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.14"
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
pydantic-version: ["pydantic-v1", "pydantic-v2"]
exclude:
- python-version: "3.14"
pydantic-version: "pydantic-v1"
os: [ windows-latest, macos-latest ]
python-version: [ "3.14" ]
pydantic-version: [ "pydantic>=2.0.2,<3.0.0" ]
include:
- os: macos-latest
python-version: "3.8"
pydantic-version: "pydantic>=1.10.0,<2.0.0"
- os: windows-latest
python-version: "3.8"
pydantic-version: "pydantic>=2.0.2,<3.0.0"
coverage: coverage
- os: ubuntu-latest
python-version: "3.9"
pydantic-version: "pydantic>=1.10.0,<2.0.0"
coverage: coverage
- os: macos-latest
python-version: "3.10"
pydantic-version: "pydantic>=2.0.2,<3.0.0"
- os: windows-latest
python-version: "3.11"
pydantic-version: "pydantic>=1.10.0,<2.0.0"
- os: ubuntu-latest
python-version: "3.12"
pydantic-version: "pydantic>=2.0.2,<3.0.0"
- os: macos-latest
python-version: "3.13"
pydantic-version: "pydantic>=1.10.0,<2.0.0"
- os: windows-latest
python-version: "3.13"
pydantic-version: "pydantic>=2.0.2,<3.0.0"
coverage: coverage
- os: ubuntu-latest
python-version: "3.14"
pydantic-version: "pydantic>=2.0.2,<3.0.0"
coverage: coverage
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
@ -80,12 +99,8 @@ jobs:
pyproject.toml
- name: Install Dependencies
run: uv pip install -r requirements-tests.txt
- name: Install Pydantic v1
if: matrix.pydantic-version == 'pydantic-v1'
run: uv pip install "pydantic>=1.10.0,<2.0.0"
- name: Install Pydantic v2
if: matrix.pydantic-version == 'pydantic-v2'
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
- name: Install Pydantic
run: uv pip install "${{ matrix.pydantic-version }}"
# TODO: Remove this once Python 3.8 is no longer supported
- name: Install older AnyIO in Python 3.8
if: matrix.python-version == '3.8'
@ -96,10 +111,12 @@ jobs:
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
# Do not store coverage for all possible combinations to avoid file size max errors in Smokeshow
- name: Store coverage files
uses: actions/upload-artifact@v4
if: matrix.coverage == 'coverage'
uses: actions/upload-artifact@v5
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
name: coverage-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/coverage/.coverage.*') }}
path: coverage
include-hidden-files: true
@ -111,7 +128,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: '3.8'
@ -126,21 +143,21 @@ jobs:
- name: Install Dependencies
run: uv pip install -r requirements-tests.txt
- name: Get coverage files
uses: actions/download-artifact@v5
uses: actions/download-artifact@v6
with:
pattern: coverage-*
path: coverage
merge-multiple: true
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: coverage-html
path: htmlcov
include-hidden-files: true
- run: coverage report --fail-under=100
# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection

View File

@ -19,7 +19,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:

View File

@ -1,6 +1,9 @@
name: Translate
on:
schedule:
- cron: "0 5 15 * *" # Run at 05:00 on the 15 of every month
workflow_dispatch:
inputs:
debug_enabled:
@ -16,7 +19,7 @@ on:
- update-outdated
- add-missing
- update-and-add
- remove-all-removable
- remove-removable
language:
description: Language to translate to as a letter code (e.g. "es" for Spanish)
type: string
@ -32,17 +35,52 @@ env:
UV_SYSTEM_PYTHON: 1
jobs:
job:
if: github.repository_owner == 'fastapi'
langs:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
langs: ${{ steps.show-langs.outputs.langs }}
commands: ${{ steps.show-langs.outputs.commands }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- name: Install Dependencies
run: uv pip install -r requirements-github-actions.txt -r requirements-translations.txt
- name: Export Language Codes
id: show-langs
run: |
echo "langs=$(python ./scripts/translate.py llm-translatable-json)" >> $GITHUB_OUTPUT
echo "commands=$(python ./scripts/translate.py commands-json)" >> $GITHUB_OUTPUT
env:
LANGUAGE: ${{ github.event.inputs.language }}
COMMAND: ${{ github.event.inputs.command }}
translate:
if: github.repository_owner == 'fastapi'
needs: langs
runs-on: ubuntu-latest
strategy:
matrix:
lang: ${{ fromJson(needs.langs.outputs.langs) }}
command: ${{ fromJson(needs.langs.outputs.commands) }}
permissions:
contents: write
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
@ -50,8 +88,6 @@ jobs:
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
@ -68,10 +104,11 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: FastAPI Translate
run: |
python ./scripts/translate.py ${{ github.event.inputs.command }}
python ./scripts/translate.py ${{ matrix.command }}
python ./scripts/translate.py make-pr
env:
GITHUB_TOKEN: ${{ secrets.FASTAPI_TRANSLATIONS }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LANGUAGE: ${{ github.event.inputs.language }}
LANGUAGE: ${{ matrix.lang }}
EN_PATH: ${{ github.event.inputs.en_path }}
COMMAND: ${{ matrix.command }}

3
.gitignore vendored
View File

@ -28,3 +28,6 @@ archive.zip
# macOS
.DS_Store
# Ignore while the setup still depends on requirements.txt files
uv.lock

View File

@ -1,9 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
@ -13,13 +11,19 @@ repos:
- --unsafe
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.3
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
- repo: local
hooks:
- id: local-script
language: unsupported
name: local script
entry: uv run ./scripts/docs.py add-permalinks-pages
args:
- --update-existing
files: ^docs/en/docs/.*\.md$

View File

@ -40,11 +40,16 @@ The key features are:
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank">OpenAPI</a> (previously known as Swagger) and <a href="https://json-schema.org/" class="external-link" target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
<small>* estimation based on tests conducted by an internal development team, building production applications.</small>
## Sponsors
<!-- sponsors -->
### Keystone Sponsor
<a href="https://fastapicloud.com" target="_blank" title="FastAPI Cloud. By the same team behind FastAPI. You code. We Cloud."><img src="https://fastapi.tiangolo.com/img/sponsors/fastapicloud.png"></a>
### Gold and Silver Sponsors
<a href="https://blockbee.io?ref=fastapi" target="_blank" title="BlockBee Cryptocurrency Payment Gateway"><img src="https://fastapi.tiangolo.com/img/sponsors/blockbee.png"></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>
@ -55,6 +60,8 @@ The key features are:
<a href="https://www.coderabbit.ai/?utm_source=fastapi&utm_medium=badge&utm_campaign=fastapi" target="_blank" title="Cut Code Review Time & Bugs in Half with CodeRabbit"><img src="https://fastapi.tiangolo.com/img/sponsors/coderabbit.png"></a>
<a href="https://subtotal.com/?utm_source=fastapi&utm_medium=sponsorship&utm_campaign=open-source" target="_blank" title="The Gold Standard in Retail Account Linking"><img src="https://fastapi.tiangolo.com/img/sponsors/subtotal.svg"></a>
<a href="https://docs.railway.com/guides/fastapi?utm_medium=integration&utm_source=docs&utm_campaign=fastapi" target="_blank" title="Deploy enterprise applications at startup speed"><img src="https://fastapi.tiangolo.com/img/sponsors/railway.png"></a>
<a href="https://serpapi.com/?utm_source=fastapi_website" target="_blank" title="SerpApi: Web Search API"><img src="https://fastapi.tiangolo.com/img/sponsors/serpapi.png"></a>
<a href="https://www.greptile.com/?utm_source=fastapi&utm_medium=sponsorship&utm_campaign=fastapi_sponsor_page" target="_blank" title="Greptile: The AI Code Reviewer"><img src="https://fastapi.tiangolo.com/img/sponsors/greptile.png"></a>
<a href="https://databento.com/?utm_source=fastapi&utm_medium=sponsor&utm_content=display" target="_blank" title="Pay as you go for market data"><img src="https://fastapi.tiangolo.com/img/sponsors/databento.svg"></a>
<a href="https://speakeasy.com/editor?utm_source=fastapi+repo&utm_medium=github+sponsorship" target="_blank" title="SDKs for your API | Speakeasy"><img src="https://fastapi.tiangolo.com/img/sponsors/speakeasy.png"></a>
<a href="https://www.svix.com/" target="_blank" title="Svix - Webhooks as a service"><img src="https://fastapi.tiangolo.com/img/sponsors/svix.svg"></a>
@ -125,7 +132,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
FastAPI stands on the shoulders of giants:
* <a href="https://www.starlette.io/" class="external-link" target="_blank">Starlette</a> for the web parts.
* <a href="https://www.starlette.dev/" class="external-link" target="_blank">Starlette</a> for the web parts.
* <a href="https://docs.pydantic.dev/" class="external-link" target="_blank">Pydantic</a> for the data parts.
## Installation
@ -231,7 +238,7 @@ INFO: Application startup complete.
<details markdown="1">
<summary>About the command <code>fastapi dev main.py</code>...</summary>
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>.
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <a href="https://www.uvicorn.dev" class="external-link" target="_blank">Uvicorn</a>.
By default, `fastapi dev` will start with auto-reload enabled for local development.
@ -446,6 +453,58 @@ For a more complete example including more features, see the <a href="https://fa
* **Cookie Sessions**
* ...and more.
### Deploy your app (optional)
You can optionally deploy your FastAPI app to <a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>, go and join the waiting list if you haven't. 🚀
If you already have a **FastAPI Cloud** account (we invited you from the waiting list 😉), you can deploy your application with one command.
Before deploying, make sure you are logged in:
<div class="termy">
```console
$ fastapi login
You are logged in to FastAPI Cloud 🚀
```
</div>
Then deploy your app:
<div class="termy">
```console
$ fastapi deploy
Deploying to FastAPI Cloud...
✅ Deployment successful!
🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev
```
</div>
That's it! Now you can access your app at that URL. ✨
#### About FastAPI Cloud
**<a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>** is built by the same author and team behind **FastAPI**.
It streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort.
It brings the same **developer experience** of building apps with FastAPI to **deploying** them to the cloud. 🎉
FastAPI Cloud is the primary sponsor and funding provider for the *FastAPI and friends* open source projects. ✨
#### Deploy to other cloud providers
FastAPI is open source and based on standards. You can deploy FastAPI apps to any cloud provider you choose.
Follow your cloud provider's guides to deploy FastAPI apps with them. 🤓
## Performance
Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as <a href="https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7" class="external-link" target="_blank">one of the fastest Python frameworks available</a>, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)
@ -472,7 +531,7 @@ Used by Starlette:
Used by FastAPI:
* <a href="https://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* <a href="https://www.uvicorn.dev" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* `fastapi-cli[standard]` - to provide the `fastapi` command.
* This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to <a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>.

View File

@ -15,7 +15,7 @@ So verwenden:
Die Tests:
## Codeschnipsel { #code-snippets}
## Codeschnipsel { #code-snippets }
//// tab | Test
@ -47,13 +47,13 @@ Das LLM wird dies wahrscheinlich falsch übersetzen. Interessant ist nur, ob es
//// tab | Info
Der Prompt-Designer kann entscheiden, ob neutrale Anführungszeichen in typografische Anführungszeichen umgewandelt werden sollen. Es ist in Ordnung, sie unverändert zu lassen.
Der Promptdesigner kann entscheiden, ob neutrale Anführungszeichen in typografische Anführungszeichen umgewandelt werden sollen. Es ist in Ordnung, sie unverändert zu lassen.
Siehe zum Beispiel den Abschnitt `### Quotes` in `docs/de/llm-prompt.md`.
////
## Anführungszeichen in Codeschnipseln { #quotes-in-code-snippets}
## Anführungszeichen in Codeschnipseln { #quotes-in-code-snippets }
//// tab | Test
@ -443,7 +443,7 @@ Für einige sprachspezifische Anweisungen, siehe z. B. den Abschnitt `### Headin
* die Workload
* das Deployment
* bereitstellen
* deployen
* das SDK
* das Software Development Kit
@ -459,7 +459,7 @@ Für einige sprachspezifische Anweisungen, siehe z. B. den Abschnitt `### Headin
* der Commit
* der Contextmanager
* die Coroutine
* die Datenbank-Session
* die Datenbanksession
* die Festplatte
* die Domain
* die Engine
@ -496,7 +496,7 @@ Für einige sprachspezifische Anweisungen, siehe z. B. den Abschnitt `### Headin
//// tab | Info
Dies ist eine nicht vollständige und nicht normative Liste von (meist) technischen Begriffen, die in der Dokumentation vorkommen. Sie kann dem Prompt-Designer helfen herauszufinden, bei welchen Begriffen das LLM Unterstützung braucht. Zum Beispiel, wenn es eine gute Übersetzung immer wieder auf eine suboptimale Übersetzung zurücksetzt. Oder wenn es Probleme hat, einen Begriff in Ihrer Sprache zu konjugieren/deklinieren.
Dies ist eine nicht vollständige und nicht normative Liste von (meist) technischen Begriffen, die in der Dokumentation vorkommen. Sie kann dem Promptdesigner helfen herauszufinden, bei welchen Begriffen das LLM Unterstützung braucht. Zum Beispiel, wenn es eine gute Übersetzung immer wieder auf eine suboptimale Übersetzung zurücksetzt. Oder wenn es Probleme hat, einen Begriff in Ihrer Sprache zu konjugieren/deklinieren.
Siehe z. B. den Abschnitt `### List of English terms and their preferred German translations` in `docs/de/llm-prompt.md`.

View File

@ -175,7 +175,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:
{* ../../docs_src/additional_responses/tutorial002.py hl[19:24,28] *}
{* ../../docs_src/additional_responses/tutorial002_py310.py hl[17:22,26] *}
/// note | Hinweis
@ -237,7 +237,7 @@ Mit dieser Technik können Sie einige vordefinierte Responses in Ihren *Pfadoper
Zum Beispiel:
{* ../../docs_src/additional_responses/tutorial004.py hl[13:17,26] *}
{* ../../docs_src/additional_responses/tutorial004_py310.py hl[11:15,24] *}
## Weitere Informationen zu OpenAPI-Responses { #more-information-about-openapi-responses }

View File

@ -70,12 +70,22 @@ Wenn Sie das hier alles verstanden haben, wissen Sie bereits, wie diese Sicherhe
Sie benötigen diese technischen Details höchstwahrscheinlich nicht.
Diese Details sind hauptsächlich nützlich, wenn Sie eine FastAPI-Anwendung haben, die älter als 0.118.0 ist, und Sie auf Probleme mit Abhängigkeiten mit `yield` stoßen.
Diese Details sind hauptsächlich nützlich, wenn Sie eine FastAPI-Anwendung haben, die älter als 0.121.0 ist, und Sie auf Probleme mit Abhängigkeiten mit `yield` stoßen.
///
Abhängigkeiten mit `yield` haben sich im Laufe der Zeit weiterentwickelt, um verschiedene Anwendungsfälle abzudecken und einige Probleme zu beheben, hier ist eine Zusammenfassung der Änderungen.
### Abhängigkeiten mit `yield` und `scope` { #dependencies-with-yield-and-scope }
In Version 0.121.0 hat FastAPI Unterstützung für `Depends(scope="function")` für Abhängigkeiten mit `yield` hinzugefügt.
Mit `Depends(scope="function")` wird der Exit-Code nach `yield` direkt nach dem Ende der *Pfadoperation-Funktion* ausgeführt, bevor die Response an den Client gesendet wird.
Und bei Verwendung von `Depends(scope="request")` (dem Default) wird der Exit-Code nach `yield` ausgeführt, nachdem die Response gesendet wurde.
Mehr dazu finden Sie in der Dokumentation zu [Abhängigkeiten mit `yield` Frühes Beenden und `scope`](../tutorial/dependencies/dependencies-with-yield.md#early-exit-and-scope).
### Abhängigkeiten mit `yield` und `StreamingResponse`, Technische Details { #dependencies-with-yield-and-streamingresponse-technical-details }
Vor FastAPI 0.118.0 wurde bei Verwendung einer Abhängigkeit mit `yield` der Exit-Code nach der *Pfadoperation-Funktion* ausgeführt, aber unmittelbar bevor die Response gesendet wurde.
@ -134,7 +144,7 @@ Dies wurde in Version 0.110.0 geändert, um unbehandelten Speicherverbrauch durc
### Hintergrundtasks und Abhängigkeiten mit `yield`, Technische Details { #background-tasks-and-dependencies-with-yield-technical-details }
Vor FastAPI 0.106.0 war das Werfen von Exceptions nach `yield` nicht möglich, der Exit-Code in Abhängigkeiten mit `yield` wurde ausgeführt, nachdem die Response gesendet wurde, sodass [Exceptionhandler](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank} bereits ausgeführt worden wären.
Vor FastAPI 0.106.0 war das Werfen von Exceptions nach `yield` nicht möglich, der Exit-Code in Abhängigkeiten mit `yield` wurde ausgeführt, nachdem die Response gesendet wurde, sodass [Exceptionhandler](../tutorial/handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank} bereits ausgeführt worden wären.
Dies war so designt, hauptsächlich um die Verwendung derselben von Abhängigkeiten „geyieldeten“ Objekte in Hintergrundtasks zu ermöglichen, da der Exit-Code erst ausgeführt wurde, nachdem die Hintergrundtasks abgeschlossen waren.

View File

@ -64,7 +64,7 @@ Wenn Sie mehr über HTTPS erfahren möchten, lesen Sie den Leitfaden [Über HTTP
///
### Wie Proxy-Forwarded-Header funktionieren
### Wie Proxy-Forwarded-Header funktionieren { #how-proxy-forwarded-headers-work }
Hier ist eine visuelle Darstellung, wie der **Proxy** weitergeleitete Header zwischen dem Client und dem **Anwendungsserver** hinzufügt:
@ -228,7 +228,7 @@ Die Übergabe des `root_path` an `FastAPI` wäre das Äquivalent zur Übergabe d
Beachten Sie, dass der Server (Uvicorn) diesen `root_path` für nichts anderes verwendet als für die Weitergabe an die Anwendung.
Aber wenn Sie mit Ihrem Browser auf <a href="http://127.0.0.1:8000" class="external-link" target="_blank">http://127.0.0.1:8000/app</a> gehen, sehen Sie die normale Response:
Aber wenn Sie mit Ihrem Browser auf <a href="http://127.0.0.1:8000/app" class="external-link" target="_blank">http://127.0.0.1:8000/app</a> gehen, sehen Sie die normale Response:
```JSON
{
@ -443,6 +443,14 @@ Die Dokumentationsoberfläche interagiert mit dem von Ihnen ausgewählten Server
///
/// note | Technische Details
Die Eigenschaft `servers` in der OpenAPI-Spezifikation ist optional.
Wenn Sie den Parameter `servers` nicht angeben und `root_path` den Wert `/` hat, wird die Eigenschaft `servers` im generierten OpenAPI-Schema standardmäßig vollständig weggelassen, was dem Äquivalent eines einzelnen Servers mit einem `url`-Wert von `/` entspricht.
///
### Den automatischen Server von `root_path` deaktivieren { #disable-automatic-server-from-root-path }
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:

View File

@ -4,7 +4,7 @@ FastAPI basiert auf **Pydantic**, und ich habe Ihnen gezeigt, wie Sie Pydantic-M
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>:
{* ../../docs_src/dataclasses/tutorial001.py hl[1,7:12,19:20] *}
{* ../../docs_src/dataclasses/tutorial001_py310.py hl[1,6:11,18:19] *}
Das ist dank **Pydantic** ebenfalls möglich, da es <a href="https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">`dataclasses` intern unterstützt</a>.
@ -32,7 +32,7 @@ Wenn Sie jedoch eine Menge Datenklassen herumliegen haben, ist dies ein guter Tr
Sie können `dataclasses` auch im Parameter `response_model` verwenden:
{* ../../docs_src/dataclasses/tutorial002.py hl[1,7:13,19] *}
{* ../../docs_src/dataclasses/tutorial002_py310.py hl[1,6:12,18] *}
Die Datenklasse wird automatisch in eine Pydantic-Datenklasse konvertiert.
@ -48,7 +48,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:
{* ../../docs_src/dataclasses/tutorial003.py hl[1,5,8:11,14:17,23:25,28] *}
{* ../../docs_src/dataclasses/tutorial003_py310.py hl[1,4,7:10,13:16,22:24,27] *}
1. Wir importieren `field` weiterhin von Standard-`dataclasses`.

View File

@ -154,7 +154,7 @@ In der technischen ASGI-Spezifikation ist dies Teil des <a href="https://asgi.re
/// info | Info
Weitere Informationen zu Starlettes `lifespan`-Handlern finden Sie in <a href="https://www.starlette.io/lifespan/" class="external-link" target="_blank">Starlettes Lifespan-Dokumentation</a>.
Weitere Informationen zu Starlettes `lifespan`-Handlern finden Sie in <a href="https://www.starlette.dev/lifespan/" class="external-link" target="_blank">Starlettes Lifespan-Dokumentation</a>.
Einschließlich, wie man Lifespan-Zustand handhabt, der in anderen Bereichen Ihres Codes verwendet werden kann.

View File

@ -94,4 +94,4 @@ Zum Beispiel:
* <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>
Um mehr über weitere verfügbare Middlewares herauszufinden, besuchen Sie <a href="https://www.starlette.io/middleware/" class="external-link" target="_blank">Starlettes Middleware-Dokumentation</a> und die <a href="https://github.com/florimondmanca/awesome-asgi" class="external-link" target="_blank">ASGI Awesome List</a>.
Um mehr über weitere verfügbare Middlewares herauszufinden, besuchen Sie <a href="https://www.starlette.dev/middleware/" class="external-link" target="_blank">Starlettes Middleware-Dokumentation</a> und die <a href="https://github.com/florimondmanca/awesome-asgi" class="external-link" target="_blank">ASGI Awesome List</a>.

View File

@ -31,7 +31,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:
{* ../../docs_src/openapi_callbacks/tutorial001.py hl[9:13,36:53] *}
{* ../../docs_src/openapi_callbacks/tutorial001_py310.py hl[7:11,34:51] *}
/// tip | Tipp
@ -90,7 +90,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.
{* ../../docs_src/openapi_callbacks/tutorial001.py hl[3,25] *}
{* ../../docs_src/openapi_callbacks/tutorial001_py310.py hl[1,23] *}
### Die Callback-*Pfadoperation* erstellen { #create-the-callback-path-operation }
@ -101,7 +101,7 @@ Sie sollte wie eine normale FastAPI-*Pfadoperation* aussehen:
* Sie sollte wahrscheinlich eine Deklaration des Bodys enthalten, die sie erhalten soll, z. B. `body: InvoiceEvent`.
* Und sie könnte auch eine Deklaration der Response enthalten, die zurückgegeben werden soll, z. B. `response_model=InvoiceEventReceived`.
{* ../../docs_src/openapi_callbacks/tutorial001.py hl[16:18,21:22,28:32] *}
{* ../../docs_src/openapi_callbacks/tutorial001_py310.py hl[14:16,19:20,26:30] *}
Es gibt zwei Hauptunterschiede zu einer normalen *Pfadoperation*:
@ -169,7 +169,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:
{* ../../docs_src/openapi_callbacks/tutorial001.py hl[35] *}
{* ../../docs_src/openapi_callbacks/tutorial001_py310.py hl[33] *}
/// tip | Tipp

View File

@ -50,7 +50,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.
{* ../../docs_src/path_operation_advanced_configuration/tutorial004.py hl[19:29] *}
{* ../../docs_src/path_operation_advanced_configuration/tutorial004_py310.py hl[17:27] *}
## Zusätzliche Responses { #additional-responses }
@ -155,13 +155,13 @@ In der folgenden Anwendung verwenden wir beispielsweise weder die integrierte Fu
//// tab | Pydantic v2
{* ../../docs_src/path_operation_advanced_configuration/tutorial007.py hl[17:22, 24] *}
{* ../../docs_src/path_operation_advanced_configuration/tutorial007_py39.py hl[15:20, 22] *}
////
//// tab | Pydantic v1
{* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py hl[17:22, 24] *}
{* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1_py39.py hl[15:20, 22] *}
////
@ -179,13 +179,13 @@ Und dann parsen wir in unserem Code diesen YAML-Inhalt direkt und verwenden dann
//// tab | Pydantic v2
{* ../../docs_src/path_operation_advanced_configuration/tutorial007.py hl[26:33] *}
{* ../../docs_src/path_operation_advanced_configuration/tutorial007_py39.py hl[24:31] *}
////
//// tab | Pydantic v1
{* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py hl[26:33] *}
{* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1_py39.py hl[24:31] *}
////

View File

@ -48,4 +48,4 @@ Und da die `Response` häufig zum Setzen von Headern und Cookies verwendet wird,
///
Um alle verfügbaren Parameter und Optionen anzuzeigen, sehen Sie sich deren <a href="https://www.starlette.io/responses/#set-cookie" class="external-link" target="_blank">Dokumentation in Starlette</a> an.
Um alle verfügbaren Parameter und Optionen anzuzeigen, sehen Sie sich deren <a href="https://www.starlette.dev/responses/#set-cookie" class="external-link" target="_blank">Dokumentation in Starlette</a> an.

View File

@ -34,7 +34,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:
{* ../../docs_src/response_directly/tutorial001.py hl[6:7,21:22] *}
{* ../../docs_src/response_directly/tutorial001_py310.py hl[5:6,20:21] *}
/// note | Technische Details

View File

@ -38,4 +38,4 @@ Und da die `Response` häufig zum Setzen von Headern und Cookies verwendet wird,
Beachten Sie, dass benutzerdefinierte proprietäre Header <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">mittels des Präfix `X-`</a> hinzugefügt werden können.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen können soll, müssen Sie diese zu Ihrer CORS-Konfiguration hinzufügen (weitere Informationen finden Sie unter [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), unter Verwendung des Parameters `expose_headers`, dokumentiert in <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlettes CORS-Dokumentation</a>.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen können soll, müssen Sie diese zu Ihrer CORS-Konfiguration hinzufügen (weitere Informationen finden Sie unter [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), unter Verwendung des Parameters `expose_headers`, dokumentiert in <a href="https://www.starlette.dev/middleware/#corsmiddleware" class="external-link" target="_blank">Starlettes CORS-Dokumentation</a>.

View File

@ -148,7 +148,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:
{* ../../docs_src/settings/app02/config.py hl[10] *}
{* ../../docs_src/settings/app02_an_py39/config.py hl[10] *}
Beachten Sie, dass wir jetzt keine Standardinstanz `settings = Settings()` erstellen.
@ -174,7 +174,7 @@ Und dann können wir das von der *Pfadoperation-Funktion* als Abhängigkeit einf
Dann wäre es sehr einfach, beim Testen ein anderes Einstellungsobjekt bereitzustellen, indem man eine Abhängigkeitsüberschreibung für `get_settings` erstellt:
{* ../../docs_src/settings/app02/test_main.py hl[9:10,13,21] *}
{* ../../docs_src/settings/app02_an_py39/test_main.py hl[9:10,13,21] *}
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.
@ -217,7 +217,7 @@ Und dann aktualisieren Sie Ihre `config.py` mit:
//// tab | Pydantic v2
{* ../../docs_src/settings/app03_an/config.py hl[9] *}
{* ../../docs_src/settings/app03_an_py39/config.py hl[9] *}
/// tip | Tipp
@ -229,7 +229,7 @@ Das Attribut `model_config` wird nur für die Pydantic-Konfiguration verwendet.
//// tab | Pydantic v1
{* ../../docs_src/settings/app03_an/config_pv1.py hl[9:10] *}
{* ../../docs_src/settings/app03_an_py39/config_pv1.py hl[9:10] *}
/// tip | Tipp

View File

@ -123,4 +123,4 @@ Und da Sie `StaticFiles` verwenden, wird diese CSS-Datei automatisch von Ihrer *
## Mehr Details { #more-details }
Weitere Informationen, einschließlich, wie man Templates testet, finden Sie in <a href="https://www.starlette.io/templates/" class="external-link" target="_blank">Starlettes Dokumentation zu Templates</a>.
Weitere Informationen, einschließlich, wie man Templates testet, finden Sie in <a href="https://www.starlette.dev/templates/" class="external-link" target="_blank">Starlettes Dokumentation zu Templates</a>.

View File

@ -5,7 +5,7 @@ Wenn Sie `lifespan` in Ihren Tests ausführen müssen, können Sie den `TestClie
{* ../../docs_src/app_testing/tutorial004.py hl[9:15,18,27:28,30:32,41:43] *}
Sie können mehr Details unter [„Lifespan in Tests ausführen in der offiziellen Starlette-Dokumentation.“](https://www.starlette.io/lifespan/#running-lifespan-in-tests) nachlesen.
Sie können mehr Details unter [„Lifespan in Tests ausführen in der offiziellen Starlette-Dokumentation.“](https://www.starlette.dev/lifespan/#running-lifespan-in-tests) nachlesen.
Für die deprecateten Events <abbr title="Hochfahren">`startup`</abbr> und <abbr title="Herunterfahren">`shutdown`</abbr> können Sie den `TestClient` wie folgt verwenden:

View File

@ -8,6 +8,6 @@ Dazu verwenden Sie den `TestClient` in einer `with`-Anweisung, eine Verbindung z
/// note | Hinweis
Weitere Informationen finden Sie in Starlettes Dokumentation zum <a href="https://www.starlette.io/testclient/#testing-websocket-sessions" class="external-link" target="_blank">Testen von WebSockets</a>.
Weitere Informationen finden Sie in Starlettes Dokumentation zum <a href="https://www.starlette.dev/testclient/#testing-websocket-sessions" class="external-link" target="_blank">Testen von WebSockets</a>.
///

View File

@ -15,7 +15,7 @@ Es gibt jedoch Situationen, in denen Sie möglicherweise direkt auf das `Request
## Details zum `Request`-Objekt { #details-about-the-request-object }
Da **FastAPI** unter der Haube eigentlich **Starlette** ist, mit einer Ebene von mehreren Tools darüber, können Sie Starlettes <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">`Request`</a>-Objekt direkt verwenden, wenn Sie es benötigen.
Da **FastAPI** unter der Haube eigentlich **Starlette** ist, mit einer Ebene von mehreren Tools darüber, können Sie Starlettes <a href="https://www.starlette.dev/requests/" class="external-link" target="_blank">`Request`</a>-Objekt direkt verwenden, wenn Sie es benötigen.
Das bedeutet allerdings auch, dass, wenn Sie Daten direkt vom `Request`-Objekt nehmen (z. B. dessen Body lesen), diese von FastAPI nicht validiert, konvertiert oder dokumentiert werden (mit OpenAPI, für die automatische API-Benutzeroberfläche).
@ -45,7 +45,7 @@ Auf die gleiche Weise können Sie wie gewohnt jeden anderen Parameter deklariere
## `Request`-Dokumentation { #request-documentation }
Weitere Details zum <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">`Request`-Objekt finden Sie in der offiziellen Starlette-Dokumentation</a>.
Weitere Details zum <a href="https://www.starlette.dev/requests/" class="external-link" target="_blank">`Request`-Objekt finden Sie in der offiziellen Starlette-Dokumentation</a>.
/// note | Technische Details

View File

@ -182,5 +182,5 @@ Wenn Sie etwas benötigen, das sich leicht in FastAPI integrieren lässt, aber r
Weitere Informationen zu Optionen finden Sie in der Dokumentation von Starlette:
* <a href="https://www.starlette.io/websockets/" class="external-link" target="_blank">Die `WebSocket`-Klasse</a>.
* <a href="https://www.starlette.io/endpoints/#websocketendpoint" class="external-link" target="_blank">Klassen-basierte Handhabung von WebSockets</a>.
* <a href="https://www.starlette.dev/websockets/" class="external-link" target="_blank">Die `WebSocket`-Klasse</a>.
* <a href="https://www.starlette.dev/endpoints/#websocketendpoint" class="external-link" target="_blank">Klassen-basierte Handhabung von WebSockets</a>.

View File

@ -417,7 +417,7 @@ Die gesamte Datenvalidierung, Datenserialisierung und automatische Modelldokumen
///
### <a href="https://www.starlette.io/" class="external-link" target="_blank">Starlette</a> { #starlette }
### <a href="https://www.starlette.dev/" class="external-link" target="_blank">Starlette</a> { #starlette }
Starlette ist ein leichtgewichtiges <abbr title="Der neue Standard für die Erstellung asynchroner Python-Webanwendungen">ASGI</abbr>-Framework/Toolkit, welches sich ideal für die Erstellung hochperformanter asynchroner Dienste eignet.
@ -462,7 +462,7 @@ Alles, was Sie also mit Starlette machen können, können Sie direkt mit **FastA
///
### <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a> { #uvicorn }
### <a href="https://www.uvicorn.dev/" class="external-link" target="_blank">Uvicorn</a> { #uvicorn }
Uvicorn ist ein blitzschneller ASGI-Server, der auf uvloop und httptools basiert.

View File

@ -1,16 +1,24 @@
# FastAPI bei Cloudanbietern bereitstellen { #deploy-fastapi-on-cloud-providers }
# FastAPI bei Cloudanbietern deployen { #deploy-fastapi-on-cloud-providers }
Sie können praktisch **jeden Cloudanbieter** verwenden, um Ihre FastAPI-Anwendung bereitzustellen.
In den meisten Fällen bieten die großen Cloudanbieter Anleitungen zum Bereitstellen von FastAPI an.
In den meisten Fällen bieten die großen Cloudanbieter Anleitungen zum Deployment von FastAPI an.
## FastAPI Cloud { #fastapi-cloud }
**<a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>** wurde vom selben Autor und Team hinter **FastAPI** entwickelt.
Es vereinfacht den Prozess des **Erstellens**, **Deployens** und **Zugreifens** auf eine API mit minimalem Aufwand.
Es bringt die gleiche **Developer-Experience** beim Erstellen von Apps mit FastAPI auch zum **Deployment** in der Cloud. 🎉
FastAPI Cloud ist der Hauptsponsor und Finanzierungsgeber für die *FastAPI and friends* Open-Source-Projekte. ✨
## Cloudanbieter Sponsoren { #cloud-providers-sponsors }
Einige Cloudanbieter ✨ [**sponsern FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨, dies stellt die kontinuierliche und gesunde **Entwicklung** von FastAPI und seinem **Ökosystem** sicher.
Einige andere Cloudanbieter ✨ [**sponsern FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨ ebenfalls. 🙇
Und es zeigt ihr wahres Engagement für FastAPI und seine **Community** (Sie), da sie Ihnen nicht nur einen **guten Service** bieten möchten, sondern auch sicherstellen möchten, dass Sie ein **gutes und gesundes Framework**, FastAPI, haben. 🙇
Vielleicht möchten Sie deren Dienste ausprobieren und deren Anleitungen folgen:
Sie könnten diese ebenfalls in Betracht ziehen, deren Anleitungen folgen und ihre Dienste ausprobieren:
* <a href="https://docs.render.com/deploy-fastapi?utm_source=deploydoc&utm_medium=referral&utm_campaign=fastapi" class="external-link" target="_blank">Render</a>
* <a href="https://docs.railway.com/guides/fastapi?utm_medium=integration&utm_source=docs&utm_campaign=fastapi" class="external-link" target="_blank">Railway</a>

View File

@ -1,6 +1,6 @@
# Deployment-Konzepte { #deployments-concepts }
Bei dem Deployment der Bereitstellung einer **FastAPI**-Anwendung, oder eigentlich jeder Art von Web-API, gibt es mehrere Konzepte, die Sie wahrscheinlich interessieren, und mithilfe der Sie die **am besten geeignete** Methode zur **Bereitstellung Ihrer Anwendung** finden können.
Bei dem Deployment der Bereitstellung einer **FastAPI**-Anwendung, oder eigentlich jeder Art von Web-API, gibt es mehrere Konzepte, die Sie wahrscheinlich interessieren, und mithilfe der Sie die **am besten geeignete** Methode zum **Deployment Ihrer Anwendung** finden können.
Einige wichtige Konzepte sind:
@ -15,11 +15,11 @@ Wir werden sehen, wie diese sich auf das **Deployment** auswirken.
Letztendlich besteht das ultimative Ziel darin, **Ihre API-Clients** auf **sichere** Weise zu versorgen, um **Unterbrechungen** zu vermeiden und die **Rechenressourcen** (z. B. entfernte Server/virtuelle Maschinen) so effizient wie möglich zu nutzen. 🚀
Ich erzähle Ihnen hier etwas mehr über diese **Konzepte**, was Ihnen hoffentlich die **Intuition** gibt, die Sie benötigen, um zu entscheiden, wie Sie Ihre API in sehr unterschiedlichen Umgebungen bereitstellen, möglicherweise sogar in **zukünftigen**, die jetzt noch nicht existieren.
Ich erzähle Ihnen hier etwas mehr über diese **Konzepte**, was Ihnen hoffentlich die **Intuition** gibt, die Sie benötigen, um zu entscheiden, wie Sie Ihre API in sehr unterschiedlichen Umgebungen deployen, möglicherweise sogar in **zukünftigen**, die jetzt noch nicht existieren.
Durch die Berücksichtigung dieser Konzepte können Sie die beste Variante der Bereitstellung **Ihrer eigenen APIs** **evaluieren und konzipieren**.
Durch die Berücksichtigung dieser Konzepte können Sie die beste Variante des Deployments **Ihrer eigenen APIs** **evaluieren und konzipieren**.
In den nächsten Kapiteln werde ich Ihnen mehr **konkrete Rezepte** für die Bereitstellung von FastAPI-Anwendungen geben.
In den nächsten Kapiteln werde ich Ihnen mehr **konkrete Rezepte** für das Deployment von FastAPI-Anwendungen geben.
Aber schauen wir uns zunächst einmal diese grundlegenden **konzeptionellen Ideen** an. Diese Konzepte gelten auch für jede andere Art von Web-API. 💡
@ -271,7 +271,7 @@ In diesem Fall müssen Sie sich darüber keine Sorgen machen. 🤷
### Beispiele für Strategien für Vorab-Schritte { #examples-of-previous-steps-strategies }
Es hängt **stark** davon ab, wie Sie **Ihr System bereitstellen**, und hängt wahrscheinlich mit der Art und Weise zusammen, wie Sie Programme starten, Neustarts durchführen, usw.
Es hängt **stark** davon ab, wie Sie **Ihr System deployen**, und hängt wahrscheinlich mit der Art und Weise zusammen, wie Sie Programme starten, Neustarts durchführen, usw.
Hier sind einige mögliche Ideen:
@ -307,7 +307,7 @@ Sie können einfache Tools wie `htop` verwenden, um die in Ihrem Server verwende
## Zusammenfassung { #recap }
Sie haben hier einige der wichtigsten Konzepte gelesen, die Sie wahrscheinlich berücksichtigen müssen, wenn Sie entscheiden, wie Sie Ihre Anwendung bereitstellen:
Sie haben hier einige der wichtigsten Konzepte gelesen, die Sie wahrscheinlich berücksichtigen müssen, wenn Sie entscheiden, wie Sie Ihre Anwendung deployen:
* Sicherheit HTTPS
* Beim Hochfahren ausführen

View File

@ -1,6 +1,6 @@
# FastAPI in Containern Docker { #fastapi-in-containers-docker }
Beim Deployment von FastAPI-Anwendungen besteht ein gängiger Ansatz darin, ein **Linux-Containerimage** zu erstellen. Normalerweise erfolgt dies mit <a href="https://www.docker.com/" class="external-link" target="_blank">**Docker**</a>. Sie können dieses Containerimage dann auf eine von mehreren möglichen Arten bereitstellen.
Beim Deployment von FastAPI-Anwendungen besteht ein gängiger Ansatz darin, ein **Linux-Containerimage** zu erstellen. Normalerweise erfolgt dies mit <a href="https://www.docker.com/" class="external-link" target="_blank">**Docker**</a>. Sie können dieses Containerimage dann auf eine von mehreren möglichen Arten deployen.
Die Verwendung von Linux-Containern bietet mehrere Vorteile, darunter **Sicherheit**, **Replizierbarkeit**, **Einfachheit** und andere.
@ -40,7 +40,7 @@ Linux-Container werden mit demselben Linux-Kernel des Hosts (Maschine, virtuelle
Auf diese Weise verbrauchen Container **wenig Ressourcen**, eine Menge vergleichbar mit der direkten Ausführung der Prozesse (eine virtuelle Maschine würde viel mehr verbrauchen).
Container verfügen außerdem über ihre eigenen **isoliert** laufenden Prozesse (üblicherweise nur einen Prozess), über ihr eigenes Dateisystem und ihr eigenes Netzwerk, was die Bereitstellung, Sicherheit, Entwicklung usw. vereinfacht.
Container verfügen außerdem über ihre eigenen **isoliert** laufenden Prozesse (üblicherweise nur einen Prozess), über ihr eigenes Dateisystem und ihr eigenes Netzwerk, was Deployment, Sicherheit, Entwicklung usw. vereinfacht.
## Was ist ein Containerimage { #what-is-a-container-image }
@ -598,7 +598,7 @@ Zum Beispiel:
* Mit einem **Kubernetes**-Cluster
* Mit einem Docker Swarm Mode-Cluster
* Mit einem anderen Tool wie Nomad
* Mit einem Cloud-Dienst, der Ihr Containerimage nimmt und es bereitstellt
* Mit einem Cloud-Dienst, der Ihr Containerimage nimmt und es deployt
## Docker-Image mit `uv` { #docker-image-with-uv }

View File

@ -0,0 +1,65 @@
# FastAPI Cloud { #fastapi-cloud }
Sie können Ihre FastAPI-App in der <a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a> mit **einem einzigen Befehl** deployen tragen Sie sich in die Warteliste ein, falls noch nicht geschehen. 🚀
## Anmelden { #login }
Stellen Sie sicher, dass Sie bereits ein **FastAPI-Cloud-Konto** haben (wir haben Sie von der Warteliste eingeladen 😉).
Melden Sie sich dann an:
<div class="termy">
```console
$ fastapi login
You are logged in to FastAPI Cloud 🚀
```
</div>
## Deployen { #deploy }
Stellen Sie Ihre App jetzt mit **einem einzigen Befehl** bereit:
<div class="termy">
```console
$ fastapi deploy
Deploying to FastAPI Cloud...
✅ Deployment successful!
🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev
```
</div>
Das wars! Jetzt können Sie Ihre App unter dieser URL aufrufen. ✨
## Über FastAPI Cloud { #about-fastapi-cloud }
**<a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>** wird vom gleichen Autor und Team hinter **FastAPI** entwickelt.
Es vereinfacht den Prozess des **Erstellens**, **Deployens** und **Nutzens** einer API mit minimalem Aufwand.
Es bringt die gleiche **Developer-Experience** beim Erstellen von Apps mit FastAPI auch zum **Deployment** in der Cloud. 🎉
Es kümmert sich außerdem um das meiste, was beim Deployen einer App nötig ist, zum Beispiel:
* HTTPS
* Replikation, mit Autoscaling basierend auf Requests
* usw.
FastAPI Cloud ist Hauptsponsor und Finanzierer der Open-Source-Projekte *FastAPI and friends*. ✨
## Bei anderen Cloudanbietern deployen { #deploy-to-other-cloud-providers }
FastAPI ist Open Source und basiert auf Standards. Sie können FastAPI-Apps bei jedem Cloudanbieter Ihrer Wahl deployen.
Folgen Sie den Anleitungen Ihres Cloudanbieters, um dort FastAPI-Apps zu deployen. 🤓
## Auf den eigenen Server deployen { #deploy-your-own-server }
Ich werde Ihnen später in diesem **Deployment-Leitfaden** auch alle Details zeigen, sodass Sie verstehen, was passiert, was geschehen muss und wie Sie FastAPI-Apps selbst deployen können, auch auf Ihre eigenen Server. 🤓

View File

@ -14,7 +14,9 @@ Das steht im Gegensatz zu den **Entwicklungsphasen**, in denen Sie ständig den
Es gibt mehrere Möglichkeiten, dies zu tun, abhängig von Ihrem spezifischen Anwendungsfall und den von Ihnen verwendeten Tools.
Sie könnten mithilfe einer Kombination von Tools selbst **einen Server bereitstellen**, Sie könnten einen **Cloud-Dienst** nutzen, der einen Teil der Arbeit für Sie erledigt, oder andere mögliche Optionen.
Sie könnten mithilfe einer Kombination von Tools selbst **einen Server deployen**, Sie könnten einen **Cloud-Dienst** nutzen, der einen Teil der Arbeit für Sie erledigt, oder andere mögliche Optionen.
Zum Beispiel haben wir, das Team hinter FastAPI, <a href="https://fastapicloud.com" class="external-link" target="_blank">**FastAPI Cloud**</a> entwickelt, um das Deployment von FastAPI-Apps in der Cloud so reibungslos wie möglich zu gestalten, mit derselben Developer-Experience wie beim Arbeiten mit FastAPI.
Ich zeige Ihnen einige der wichtigsten Konzepte, die Sie beim Deployment einer **FastAPI**-Anwendung wahrscheinlich berücksichtigen sollten (obwohl das meiste davon auch für jede andere Art von Webanwendung gilt).

View File

@ -52,7 +52,7 @@ Das Wichtigste, was Sie benötigen, um eine **FastAPI**-Anwendung (oder eine and
Es gibt mehrere Alternativen, einschließlich:
* <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a>: ein hochperformanter ASGI-Server.
* <a href="https://www.uvicorn.dev/" class="external-link" target="_blank">Uvicorn</a>: ein hochperformanter ASGI-Server.
* <a href="https://hypercorn.readthedocs.io/" class="external-link" target="_blank">Hypercorn</a>: ein ASGI-Server, der unter anderem kompatibel mit HTTP/2 und Trio ist.
* <a href="https://github.com/django/daphne" class="external-link" target="_blank">Daphne</a>: der für Django Channels entwickelte ASGI-Server.
* <a href="https://github.com/emmett-framework/granian" class="external-link" target="_blank">Granian</a>: Ein Rust HTTP-Server für Python-Anwendungen.

View File

@ -11,7 +11,7 @@ Schauen wir uns die Deployment-Konzepte von früher noch einmal an:
Bis zu diesem Punkt, in allen Tutorials in der Dokumentation, haben Sie wahrscheinlich ein **Serverprogramm** ausgeführt, zum Beispiel mit dem `fastapi`-Befehl, der Uvicorn startet, und einen **einzelnen Prozess** ausführt.
Wenn Sie Anwendungen bereitstellen, möchten Sie wahrscheinlich eine gewisse **Replikation von Prozessen**, um **mehrere Kerne** zu nutzen und mehr <abbr title="Request Anfrage: Daten, die der Client zum Server sendet">Requests</abbr> bearbeiten zu können.
Wenn Sie Anwendungen deployen, möchten Sie wahrscheinlich eine gewisse **Replikation von Prozessen**, um **mehrere Kerne** zu nutzen und mehr <abbr title="Request Anfrage: Daten, die der Client zum Server sendet">Requests</abbr> bearbeiten zu können.
Wie Sie im vorherigen Kapitel über [Deployment-Konzepte](concepts.md){.internal-link target=_blank} gesehen haben, gibt es mehrere Strategien, die Sie anwenden können.

View File

@ -52,7 +52,7 @@ FastAPI CLI nimmt den Pfad zu Ihrem Python-Programm (z. B. `main.py`), erkennt a
Für die Produktion würden Sie stattdessen `fastapi run` verwenden. 🚀
Intern verwendet das **FastAPI CLI** <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>, einen leistungsstarken, produktionsreifen, ASGI-Server. 😎
Intern verwendet das **FastAPI CLI** <a href="https://www.uvicorn.dev" class="external-link" target="_blank">Uvicorn</a>, einen leistungsstarken, produktionsreifen, ASGI-Server. 😎
## `fastapi dev` { #fastapi-dev }
@ -66,7 +66,7 @@ Das Ausführen von `fastapi run` startet FastAPI standardmäßig im Produktionsm
Standardmäßig ist **Autoreload** deaktiviert. Es horcht auch auf der IP-Adresse `0.0.0.0`, was alle verfügbaren IP-Adressen bedeutet, so wird es öffentlich zugänglich für jeden, der mit der Maschine kommunizieren kann. So würden Sie es normalerweise in der Produktion ausführen, beispielsweise in einem Container.
In den meisten Fällen würden (und sollten) Sie einen „Terminierungsproxy“ haben, der HTTPS für Sie verwaltet. Dies hängt davon ab, wie Sie Ihre Anwendung bereitstellen. Ihr Anbieter könnte dies für Sie erledigen, oder Sie müssen es selbst einrichten.
In den meisten Fällen würden (und sollten) Sie einen „Terminierungsproxy“ haben, der HTTPS für Sie verwaltet. Dies hängt davon ab, wie Sie Ihre Anwendung deployen. Ihr Anbieter könnte dies für Sie erledigen, oder Sie müssen es selbst einrichten.
/// tip | Tipp

View File

@ -159,7 +159,7 @@ Jede Integration wurde so entworfen, dass sie so einfach zu nutzen ist (mit Abh
## Starlette Merkmale { #starlette-features }
**FastAPI** ist vollkommen kompatibel (und basiert auf) <a href="https://www.starlette.io/" class="external-link" target="_blank"><strong>Starlette</strong></a>. Das bedeutet, wenn Sie eigenen Starlette Quellcode haben, funktioniert der.
**FastAPI** ist vollkommen kompatibel (und basiert auf) <a href="https://www.starlette.dev/" class="external-link" target="_blank"><strong>Starlette</strong></a>. Das bedeutet, wenn Sie eigenen Starlette Quellcode haben, funktioniert der.
`FastAPI` ist tatsächlich eine Unterklasse von `Starlette`. Wenn Sie also bereits Starlette kennen oder benutzen, das meiste funktioniert genau so.

View File

@ -58,7 +58,7 @@ Nachdem ich mehrere Alternativen getestet hatte, entschied ich, dass ich <a href
Dann habe ich zu dessen Code beigetragen, um es vollständig mit JSON Schema kompatibel zu machen, und so verschiedene Möglichkeiten zum Definieren von einschränkenden Deklarationen (Constraints) zu unterstützen, und die Editorunterstützung (Typprüfungen, Codevervollständigung) zu verbessern, basierend auf den Tests in mehreren Editoren.
Während der Entwicklung habe ich auch zu <a href="https://www.starlette.io/" class="external-link" target="_blank">**Starlette**</a> beigetragen, der anderen Schlüsselanforderung.
Während der Entwicklung habe ich auch zu <a href="https://www.starlette.dev/" class="external-link" target="_blank">**Starlette**</a> beigetragen, der anderen Schlüsselanforderung.
## Entwicklung { #development }

View File

@ -0,0 +1,17 @@
# Alte 403-Authentifizierungsfehler-Statuscodes verwenden { #use-old-403-authentication-error-status-codes }
Vor FastAPI-Version `0.122.0` verwendeten die integrierten Sicherheits-Utilities den HTTP-Statuscode `403 Forbidden`, wenn sie dem Client nach einer fehlgeschlagenen Authentifizierung einen Fehler zurückgaben.
Ab FastAPI-Version `0.122.0` verwenden sie den passenderen HTTP-Statuscode `401 Unauthorized` und geben in der Response einen sinnvollen `WWW-Authenticate`-Header zurück, gemäß den HTTP-Spezifikationen, <a href="https://datatracker.ietf.org/doc/html/rfc7235#section-3.1" class="external-link" target="_blank">RFC 7235</a>, <a href="https://datatracker.ietf.org/doc/html/rfc9110#name-401-unauthorized" class="external-link" target="_blank">RFC 9110</a>.
Aber falls Ihre Clients aus irgendeinem Grund vom alten Verhalten abhängen, können Sie darauf zurückgreifen, indem Sie in Ihren Sicherheitsklassen die Methode `make_not_authenticated_error` überschreiben.
Sie können beispielsweise eine Unterklasse von `HTTPBearer` erstellen, die einen Fehler `403 Forbidden` zurückgibt, statt des Default-`401 Unauthorized`-Fehlers:
{* ../../docs_src/authentication_error_status_code/tutorial001_an_py39.py hl[9:13] *}
/// tip | Tipp
Beachten Sie, dass die Funktion die Exception-Instanz zurückgibt; sie wirft sie nicht. Das Werfen erfolgt im restlichen internen Code.
///

View File

@ -40,7 +40,7 @@ FastAPI enthält einige Defaultkonfigurationsparameter, die für die meisten Anw
Es umfasst die folgenden Defaultkonfigurationen:
{* ../../fastapi/openapi/docs.py ln[8:23] hl[17:23] *}
{* ../../fastapi/openapi/docs.py ln[9:24] hl[18:24] *}
Sie können jede davon überschreiben, indem Sie im Argument `swagger_ui_parameters` einen anderen Wert festlegen.

View File

@ -42,7 +42,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.
{* ../../docs_src/custom_request_and_route/tutorial001.py hl[8:15] *}
{* ../../docs_src/custom_request_and_route/tutorial001_an_py310.py hl[9:16] *}
### Eine benutzerdefinierte `GzipRoute`-Klasse erstellen { #create-a-custom-gziproute-class }
@ -54,7 +54,7 @@ Diese Methode gibt eine Funktion zurück. Und diese Funktion empfängt einen <ab
Hier verwenden wir sie, um aus dem ursprünglichen Request einen `GzipRequest` zu erstellen.
{* ../../docs_src/custom_request_and_route/tutorial001.py hl[18:26] *}
{* ../../docs_src/custom_request_and_route/tutorial001_an_py310.py hl[19:27] *}
/// note | Technische Details
@ -66,7 +66,7 @@ Das `scope`-`dict` und die `receive`-Funktion sind beide Teil der ASGI-Spezifika
Und diese beiden Dinge, `scope` und `receive`, werden benötigt, um eine neue `Request`-Instanz zu erstellen.
Um mehr über den `Request` zu erfahren, schauen Sie sich <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">Starlettes Dokumentation zu Requests</a> an.
Um mehr über den `Request` zu erfahren, schauen Sie sich <a href="https://www.starlette.dev/requests/" class="external-link" target="_blank">Starlettes Dokumentation zu Requests</a> an.
///
@ -92,18 +92,18 @@ 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:
{* ../../docs_src/custom_request_and_route/tutorial002.py hl[13,15] *}
{* ../../docs_src/custom_request_and_route/tutorial002_an_py310.py hl[14,16] *}
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:
{* ../../docs_src/custom_request_and_route/tutorial002.py hl[16:18] *}
{* ../../docs_src/custom_request_and_route/tutorial002_an_py310.py hl[17:19] *}
## Benutzerdefinierte `APIRoute`-Klasse in einem Router { #custom-apiroute-class-in-a-router }
Sie können auch den Parameter `route_class` eines `APIRouter` festlegen:
{* ../../docs_src/custom_request_and_route/tutorial003.py hl[26] *}
{* ../../docs_src/custom_request_and_route/tutorial003_py310.py hl[26] *}
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:
{* ../../docs_src/custom_request_and_route/tutorial003.py hl[13:20] *}
{* ../../docs_src/custom_request_and_route/tutorial003_py310.py hl[13:20] *}

View File

@ -0,0 +1,133 @@
# Von Pydantic v1 zu Pydantic v2 migrieren { #migrate-from-pydantic-v1-to-pydantic-v2 }
Wenn Sie eine ältere FastAPI-App haben, nutzen Sie möglicherweise Pydantic Version 1.
FastAPI unterstützt seit Version 0.100.0 sowohl Pydantic v1 als auch v2.
Wenn Sie Pydantic v2 installiert hatten, wurde dieses verwendet. Wenn stattdessen Pydantic v1 installiert war, wurde jenes verwendet.
Pydantic v1 ist jetzt deprecatet und die Unterstützung dafür wird in den nächsten Versionen von FastAPI entfernt, Sie sollten also zu **Pydantic v2 migrieren**. Auf diese Weise erhalten Sie die neuesten Features, Verbesserungen und Fixes.
/// warning | Achtung
Außerdem hat das Pydantic-Team die Unterstützung für Pydantic v1 in den neuesten Python-Versionen eingestellt, beginnend mit **Python 3.14**.
Wenn Sie die neuesten Features von Python nutzen möchten, müssen Sie sicherstellen, dass Sie Pydantic v2 verwenden.
///
Wenn Sie eine ältere FastAPI-App mit Pydantic v1 haben, zeige ich Ihnen hier, wie Sie sie zu Pydantic v2 migrieren, und die **neuen Features in FastAPI 0.119.0**, die Ihnen bei einer schrittweisen Migration helfen.
## Offizieller Leitfaden { #official-guide }
Pydantic hat einen offiziellen <a href="https://docs.pydantic.dev/latest/migration/" class="external-link" target="_blank">Migrationsleitfaden</a> von v1 zu v2.
Er enthält auch, was sich geändert hat, wie Validierungen nun korrekter und strikter sind, mögliche Stolpersteine, usw.
Sie können ihn lesen, um besser zu verstehen, was sich geändert hat.
## Tests { #tests }
Stellen Sie sicher, dass Sie [Tests](../tutorial/testing.md){.internal-link target=_blank} für Ihre App haben und diese in Continuous Integration (CI) ausführen.
Auf diese Weise können Sie das Update durchführen und sicherstellen, dass weiterhin alles wie erwartet funktioniert.
## `bump-pydantic` { #bump-pydantic }
In vielen Fällen, wenn Sie reguläre Pydantic-Modelle ohne Anpassungen verwenden, können Sie den Großteil des Prozesses der Migration von Pydantic v1 auf Pydantic v2 automatisieren.
Sie können <a href="https://github.com/pydantic/bump-pydantic" class="external-link" target="_blank">`bump-pydantic`</a> vom selben Pydantic-Team verwenden.
Dieses Tool hilft Ihnen, den Großteil des zu ändernden Codes automatisch anzupassen.
Danach können Sie die Tests ausführen und prüfen, ob alles funktioniert. Falls ja, sind Sie fertig. 😎
## Pydantic v1 in v2 { #pydantic-v1-in-v2 }
Pydantic v2 enthält alles aus Pydantic v1 als Untermodul `pydantic.v1`.
Das bedeutet, Sie können die neueste Version von Pydantic v2 installieren und die alten Pydanticv1Komponenten aus diesem Untermodul importieren und verwenden, als hätten Sie das alte Pydantic v1 installiert.
{* ../../docs_src/pydantic_v1_in_v2/tutorial001_an_py310.py hl[1,4] *}
### FastAPI-Unterstützung für Pydantic v1 in v2 { #fastapi-support-for-pydantic-v1-in-v2 }
Seit FastAPI 0.119.0 gibt es außerdem eine teilweise Unterstützung für Pydantic v1 innerhalb von Pydantic v2, um die Migration auf v2 zu erleichtern.
Sie könnten also Pydantic auf die neueste Version 2 aktualisieren und die Importe so ändern, dass das Untermodul `pydantic.v1` verwendet wird, und in vielen Fällen würde es einfach funktionieren.
{* ../../docs_src/pydantic_v1_in_v2/tutorial002_an_py310.py hl[2,5,15] *}
/// warning | Achtung
Beachten Sie, dass, da das PydanticTeam Pydantic v1 in neueren PythonVersionen nicht mehr unterstützt, beginnend mit Python 3.14, auch die Verwendung von `pydantic.v1` unter Python 3.14 und höher nicht unterstützt wird.
///
### Pydantic v1 und v2 in derselben App { #pydantic-v1-and-v2-on-the-same-app }
Es wird von Pydantic **nicht unterstützt**, dass ein Pydanticv2Modell Felder hat, die als Pydanticv1Modelle definiert sind, und umgekehrt.
```mermaid
graph TB
subgraph "❌ Nicht unterstützt"
direction TB
subgraph V2["Pydantic-v2-Modell"]
V1Field["Pydantic-v1-Modell"]
end
subgraph V1["Pydantic-v1-Modell"]
V2Field["Pydantic-v2-Modell"]
end
end
style V2 fill:#f9fff3
style V1 fill:#fff6f0
style V1Field fill:#fff6f0
style V2Field fill:#f9fff3
```
... aber Sie können getrennte Modelle, die Pydantic v1 bzw. v2 nutzen, in derselben App verwenden.
```mermaid
graph TB
subgraph "✅ Unterstützt"
direction TB
subgraph V2["Pydantic-v2-Modell"]
V2Field["Pydantic-v2-Modell"]
end
subgraph V1["Pydantic-v1-Modell"]
V1Field["Pydantic-v1-Modell"]
end
end
style V2 fill:#f9fff3
style V1 fill:#fff6f0
style V1Field fill:#fff6f0
style V2Field fill:#f9fff3
```
In einigen Fällen ist es sogar möglich, sowohl Pydanticv1 als auch Pydanticv2Modelle in derselben **Pfadoperation** Ihrer FastAPIApp zu verwenden:
{* ../../docs_src/pydantic_v1_in_v2/tutorial003_an_py310.py hl[2:3,6,12,21:22] *}
Im obigen Beispiel ist das Eingabemodell ein Pydanticv1Modell, und das Ausgabemodell (definiert in `response_model=ItemV2`) ist ein Pydanticv2Modell.
### Pydantic v1 Parameter { #pydantic-v1-parameters }
Wenn Sie einige der FastAPI-spezifischen Tools für Parameter wie `Body`, `Query`, `Form`, usw. zusammen mit Pydanticv1Modellen verwenden müssen, können Sie die aus `fastapi.temp_pydantic_v1_params` importieren, während Sie die Migration zu Pydantic v2 abschließen:
{* ../../docs_src/pydantic_v1_in_v2/tutorial004_an_py310.py hl[4,18] *}
### In Schritten migrieren { #migrate-in-steps }
/// tip | Tipp
Probieren Sie zuerst `bump-pydantic` aus. Wenn Ihre Tests erfolgreich sind und das funktioniert, sind Sie mit einem einzigen Befehl fertig. ✨
///
Wenn `bump-pydantic` für Ihren Anwendungsfall nicht funktioniert, können Sie die Unterstützung für Pydanticv1 und Pydanticv2Modelle in derselben App nutzen, um die Migration zu Pydantic v2 schrittweise durchzuführen.
Sie könnten zuerst Pydantic auf die neueste Version 2 aktualisieren und die Importe so ändern, dass für all Ihre Modelle `pydantic.v1` verwendet wird.
Anschließend können Sie beginnen, Ihre Modelle gruppenweise von Pydantic v1 auf v2 zu migrieren in kleinen, schrittweisen Etappen. 🚶

View File

@ -46,20 +46,26 @@ Seine Schlüssel-Merkmale sind:
* **Robust**: Erhalten Sie produktionsreifen Code. Mit automatischer, interaktiver Dokumentation.
* **Standards-basiert**: Basierend auf (und vollständig kompatibel mit) den offenen Standards für APIs: <a href="https://github.com/OAI/OpenAPI-Specification" class="external-link" target="_blank">OpenAPI</a> (früher bekannt als Swagger) und <a href="https://json-schema.org/" class="external-link" target="_blank">JSON Schema</a>.
<small>* Schätzung basierend auf Tests in einem internen Entwicklungsteam, das Produktionsanwendungen erstellt.</small>
<small>* Schätzung basierend auf Tests, die von einem internen Entwicklungsteam durchgeführt wurden, das Produktionsanwendungen erstellt.</small>
## Sponsoren { #sponsors }
<!-- sponsors -->
{% if sponsors %}
### Keystone-Sponsor { #keystone-sponsor }
{% for sponsor in sponsors.keystone -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor -%}
### Gold- und Silber-Sponsoren { #gold-and-silver-sponsors }
{% for sponsor in sponsors.gold -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor -%}
{%- for sponsor in sponsors.silver -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}" style="border-radius:15px"></a>
{% endfor %}
{% endif %}
<!-- /sponsors -->
@ -123,7 +129,7 @@ Wenn Sie eine <abbr title="Command Line Interface Kommandozeilen-Schnittstel
FastAPI steht auf den Schultern von Giganten:
* <a href="https://www.starlette.io/" class="external-link" target="_blank">Starlette</a> für die Webanteile.
* <a href="https://www.starlette.dev/" class="external-link" target="_blank">Starlette</a> für die Webanteile.
* <a href="https://docs.pydantic.dev/" class="external-link" target="_blank">Pydantic</a> für die Datenanteile.
## Installation { #installation }
@ -229,7 +235,7 @@ INFO: Application startup complete.
<details markdown="1">
<summary>Was der Befehl <code>fastapi dev main.py</code> macht ...</summary>
Der Befehl `fastapi dev` liest Ihre `main.py`-Datei, erkennt die **FastAPI**-App darin und startet einen Server mit <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>.
Der Befehl `fastapi dev` liest Ihre `main.py`-Datei, erkennt die **FastAPI**-App darin und startet einen Server mit <a href="https://www.uvicorn.dev" class="external-link" target="_blank">Uvicorn</a>.
Standardmäßig wird `fastapi dev` mit aktiviertem Auto-Reload für die lokale Entwicklung gestartet.
@ -444,6 +450,58 @@ Für ein vollständigeres Beispiel, mit weiteren Funktionen, siehe das <a href="
* **Cookie-Sessions**
* ... und mehr.
### Ihre App deployen (optional) { #deploy-your-app-optional }
Optional können Sie Ihre FastAPI-App in die <a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a> deployen, treten Sie der Warteliste bei, falls noch nicht geschehen. 🚀
Wenn Sie bereits ein **FastAPI Cloud**-Konto haben (wir haben Sie von der Warteliste eingeladen 😉), können Sie Ihre Anwendung mit einem einzigen Befehl deployen.
Stellen Sie vor dem Deployen sicher, dass Sie eingeloggt sind:
<div class="termy">
```console
$ fastapi login
You are logged in to FastAPI Cloud 🚀
```
</div>
Stellen Sie dann Ihre App bereit:
<div class="termy">
```console
$ fastapi deploy
Deploying to FastAPI Cloud...
✅ Deployment successful!
🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev
```
</div>
Das wars! Jetzt können Sie unter dieser URL auf Ihre App zugreifen. ✨
#### Über FastAPI Cloud { #about-fastapi-cloud }
**<a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>** wird vom selben Autor und Team hinter **FastAPI** entwickelt.
Es vereinfacht den Prozess des **Erstellens**, **Deployens** und **Zugreifens** auf eine API mit minimalem Aufwand.
Es bringt die gleiche **Developer-Experience** beim Erstellen von Apps mit FastAPI auch zum **Deployment** in der Cloud. 🎉
FastAPI Cloud ist der Hauptsponsor und Finanzierer der „FastAPI and friends“ Open-Source-Projekte. ✨
#### Bei anderen Cloudanbietern deployen { #deploy-to-other-cloud-providers }
FastAPI ist Open Source und basiert auf Standards. Sie können FastAPI-Apps bei jedem Cloudanbieter Ihrer Wahl deployen.
Folgen Sie den Anleitungen Ihres Cloudanbieters, um FastAPI-Apps dort bereitzustellen. 🤓
## Performanz { #performance }
Unabhängige TechEmpower-Benchmarks zeigen **FastAPI**-Anwendungen, die unter Uvicorn laufen, als <a href="https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7" class="external-link" target="_blank">eines der schnellsten verfügbaren Python-Frameworks</a>, nur hinter Starlette und Uvicorn selbst (intern von FastAPI verwendet). (*)
@ -470,7 +528,7 @@ Verwendet von Starlette:
Verwendet von FastAPI:
* <a href="https://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> für den Server, der Ihre Anwendung lädt und bereitstellt. Dies umfasst `uvicorn[standard]`, das einige Abhängigkeiten (z. B. `uvloop`) beinhaltet, die für eine Bereitstellung mit hoher Performanz benötigt werden.
* <a href="https://www.uvicorn.dev" target="_blank"><code>uvicorn</code></a> für den Server, der Ihre Anwendung lädt und bereitstellt. Dies umfasst `uvicorn[standard]`, das einige Abhängigkeiten (z. B. `uvloop`) beinhaltet, die für eine Bereitstellung mit hoher Performanz benötigt werden.
* `fastapi-cli[standard]` um den `fastapi`-Befehl bereitzustellen.
* Dies beinhaltet `fastapi-cloud-cli`, das es Ihnen ermöglicht, Ihre FastAPI-Anwendung auf <a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a> bereitzustellen.

View File

@ -14,15 +14,15 @@ GitHub-Repository: <a href="https://github.com/tiangolo/full-stack-fastapi-templ
- 💾 [PostgreSQL](https://www.postgresql.org) als SQL-Datenbank.
- 🚀 [React](https://react.dev) für das Frontend.
- 💃 Verwendung von TypeScript, Hooks, [Vite](https://vitejs.dev) und anderen Teilen eines modernen Frontend-Stacks.
- 🎨 [Chakra UI](https://chakra-ui.com) für die Frontend-Komponenten.
- 🎨 [Tailwind CSS](https://tailwindcss.com) und [shadcn/ui](https://ui.shadcn.com) für die Frontend-Komponenten.
- 🤖 Ein automatisch generierter Frontend-Client.
- 🧪 [Playwright](https://playwright.dev) für End-to-End-Tests.
- 🦇 Unterstützung des Dunkelmodus.
- 🦇 „Dark-Mode“-Unterstützung.
- 🐋 [Docker Compose](https://www.docker.com) für Entwicklung und Produktion.
- 🔒 Sicheres Passwort-Hashing standardmäßig.
- 🔑 JWT-Token-Authentifizierung.
- 🔑 JWT (JSON Web Token)-Token-Authentifizierung.
- 📫 E-Mail-basierte Passwortwiederherstellung.
- ✅ Tests mit [Pytest](https://pytest.org).
- 📞 [Traefik](https://traefik.io) als Reverse-Proxy / Load Balancer.
- 🚢 Deployment-Anleitungen unter Verwendung von Docker Compose, einschließlich der Einrichtung eines Frontend-Traefik-Proxys zur Handhabung automatischer HTTPS-Zertifikate.
- 🏭 CI (kontinuierliche Integration) und CD (kontinuierliche Bereitstellung) basierend auf GitHub Actions.
- 🏭 CI (kontinuierliche Integration) und CD (kontinuierliches Deployment) basierend auf GitHub Actions.

View File

@ -1,3 +1,3 @@
# Ressourcen { #resources }
Zusätzliche Ressourcen, externe Links, Artikel und mehr. ✈️
Zusätzliche Ressourcen, externe Links und mehr. ✈️

View File

@ -63,7 +63,7 @@ Und dann schreibt ein weiterer Hintergrundtask, der in der *Pfadoperation-Funkti
## Technische Details { #technical-details }
Die Klasse `BackgroundTasks` stammt direkt von <a href="https://www.starlette.io/background/" class="external-link" target="_blank">`starlette.background`</a>.
Die Klasse `BackgroundTasks` stammt direkt von <a href="https://www.starlette.dev/background/" class="external-link" target="_blank">`starlette.background`</a>.
Sie wird direkt in FastAPI importiert/inkludiert, sodass Sie sie von `fastapi` importieren können und vermeiden, versehentlich das alternative `BackgroundTask` (ohne das `s` am Ende) von `starlette.background` zu importieren.
@ -71,7 +71,7 @@ Indem Sie nur `BackgroundTasks` (und nicht `BackgroundTask`) verwenden, ist es d
Es ist immer noch möglich, `BackgroundTask` allein in FastAPI zu verwenden, aber Sie müssen das Objekt in Ihrem Code erstellen und eine Starlette-`Response` zurückgeben, die es enthält.
Weitere Details finden Sie in <a href="https://www.starlette.io/background/" class="external-link" target="_blank">Starlettes offizieller Dokumentation für Hintergrundtasks</a>.
Weitere Details finden Sie in <a href="https://www.starlette.dev/background/" class="external-link" target="_blank">Starlettes offizieller Dokumentation für Hintergrundtasks</a>.
## Vorbehalt { #caveat }

View File

@ -85,9 +85,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_an_py39/routers/users.py hl[1,3] title["app/routers/users.py"] *}
### *Pfadoperationen* mit `APIRouter` { #path-operations-with-apirouter }
@ -95,9 +93,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_an_py39/routers/users.py hl[6,11,16] title["app/routers/users.py"] *}
Sie können sich `APIRouter` als eine „Mini-`FastAPI`“-Klasse vorstellen.
@ -121,35 +117,7 @@ Also fügen wir sie in ihr eigenes `dependencies`-Modul (`app/dependencies.py`)
Wir werden nun eine einfache Abhängigkeit verwenden, um einen benutzerdefinierten `X-Token`-Header zu lesen:
//// tab | Python 3.9+
```Python hl_lines="3 6-8" title="app/dependencies.py"
{!> ../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="1 5-7" title="app/dependencies.py"
{!> ../../docs_src/bigger_applications/app_an/dependencies.py!}
```
////
//// tab | Python 3.8+ nicht annotiert
/// tip | Tipp
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_an_py39/dependencies.py hl[3,6:8] title["app/dependencies.py"] *}
/// tip | Tipp
@ -181,9 +149,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_an_py39/routers/items.py hl[5:10,16,21] title["app/routers/items.py"] *}
Da der Pfad jeder *Pfadoperation* mit `/` beginnen muss, wie in:
@ -242,9 +208,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_an_py39/routers/items.py hl[3] title["app/routers/items.py"] *}
#### Wie relative Importe funktionieren { #how-relative-imports-work }
@ -315,9 +279,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_an_py39/routers/items.py hl[30:31] title["app/routers/items.py"] *}
/// tip | Tipp
@ -343,17 +305,13 @@ 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_an_py39/main.py hl[1,3,7] title["app/main.py"] *}
### Den `APIRouter` importieren { #import-the-apirouter }
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_an_py39/main.py hl[4:5] title["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.
@ -416,17 +374,13 @@ 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_an_py39/main.py hl[5] title["app/main.py"] *}
### Die `APIRouter` für `users` und `items` inkludieren { #include-the-apirouters-for-users-and-items }
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_an_py39/main.py hl[10:11] title["app/main.py"] *}
/// info | Info
@ -466,17 +420,13 @@ 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_an_py39/internal/admin.py hl[3] title["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.
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_an_py39/main.py hl[14:17] title["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.
@ -497,9 +447,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_an_py39/main.py hl[21:23] title["app/main.py"] *}
und es wird korrekt funktionieren, zusammen mit allen anderen *Pfadoperationen*, die mit `app.include_router()` hinzugefügt wurden.

View File

@ -50,7 +50,7 @@ Ihre API hat jetzt die Macht, ihre eigene <abbr title="Das ist ein Scherz, nur f
Sie können die Modellkonfiguration von Pydantic verwenden, um `extra` Felder zu verbieten (`forbid`):
{* ../../docs_src/cookie_param_models/tutorial002_an_py39.py hl[10] *}
{* ../../docs_src/cookie_param_models/tutorial002_an_py310.py hl[10] *}
Wenn ein Client versucht, einige **zusätzliche Cookies** zu senden, erhält er eine **Error-<abbr title="Response Antwort: Daten, die der Server zum anfragenden Client zurücksendet">Response</abbr>**.

View File

@ -184,6 +184,51 @@ Wenn Sie in dem Code der *Pfadoperation-Funktion* irgendeine Exception auslösen
///
## Frühes Beenden und `scope` { #early-exit-and-scope }
Normalerweise wird der Exit-Code von Abhängigkeiten mit `yield` ausgeführt **nachdem die Response** an den Client gesendet wurde.
Wenn Sie aber wissen, dass Sie die Abhängigkeit nach der Rückkehr aus der *Pfadoperation-Funktion* nicht mehr benötigen, können Sie `Depends(scope="function")` verwenden, um FastAPI mitzuteilen, dass es die Abhängigkeit nach der Rückkehr aus der *Pfadoperation-Funktion* schließen soll, jedoch **bevor** die **Response gesendet wird**.
{* ../../docs_src/dependencies/tutorial008e_an_py39.py hl[12,16] *}
`Depends()` erhält einen `scope`-Parameter, der sein kann:
* `"function"`: startet die Abhängigkeit vor der *Pfadoperation-Funktion*, die den Request bearbeitet, beendet die Abhängigkeit nach dem Ende der *Pfadoperation-Funktion*, aber **bevor** die Response an den Client zurückgesendet wird. Die Abhängigkeitsfunktion wird also **um** die *Pfadoperation-**Funktion*** **herum** ausgeführt.
* `"request"`: startet die Abhängigkeit vor der *Pfadoperation-Funktion*, die den Request bearbeitet (ähnlich wie bei `"function"`), beendet sie jedoch **nachdem** die Response an den Client zurückgesendet wurde. Die Abhängigkeitsfunktion wird also **um** den **Request**- und Response-Zyklus **herum** ausgeführt.
Wenn nicht angegeben und die Abhängigkeit `yield` hat, hat sie standardmäßig einen `scope` von `"request"`.
### `scope` für Unterabhängigkeiten { #scope-for-sub-dependencies }
Wenn Sie eine Abhängigkeit mit `scope="request"` (dem Default) deklarieren, muss jede Unterabhängigkeit ebenfalls einen `scope` von `"request"` haben.
Eine Abhängigkeit mit `scope` von `"function"` kann jedoch Abhängigkeiten mit `scope` von `"function"` und `scope` von `"request"` haben.
Das liegt daran, dass jede Abhängigkeit in der Lage sein muss, ihren Exit-Code vor den Unterabhängigkeiten auszuführen, da sie diese während ihres Exit-Codes möglicherweise noch verwenden muss.
```mermaid
sequenceDiagram
participant client as Client
participant dep_req as Abhängigkeit scope="request"
participant dep_func as Abhängigkeit scope="function"
participant operation as Pfadoperation
client ->> dep_req: Startet den Request
Note over dep_req: Führt den Code bis zum yield aus
dep_req ->> dep_func: Reicht Abhängigkeit weiter
Note over dep_func: Führt den Code bis zum yield aus
dep_func ->> operation: Führt Pfadoperation mit Abhängigkeit aus
operation ->> dep_func: Kehrt aus Pfadoperation zurück
Note over dep_func: Führt Code nach yield aus
Note over dep_func: ✅ Abhängigkeit geschlossen
dep_func ->> client: Sendet Response an Client
Note over client: Response gesendet
Note over dep_req: Führt Code nach yield aus
Note over dep_req: ✅ Abhängigkeit geschlossen
```
## Abhängigkeiten mit `yield`, `HTTPException`, `except` und Hintergrundtasks { #dependencies-with-yield-httpexception-except-and-background-tasks }
Abhängigkeiten mit `yield` haben sich im Laufe der Zeit weiterentwickelt, um verschiedene Anwendungsfälle abzudecken und einige Probleme zu beheben.

View File

@ -143,6 +143,42 @@ Es gibt dutzende Alternativen, die alle auf OpenAPI basieren. Sie können jede d
Ebenfalls können Sie es verwenden, um automatisch Code für Clients zu generieren, die mit Ihrer API kommunizieren. Zum Beispiel für Frontend-, Mobile- oder IoT-Anwendungen.
### Ihre App deployen (optional) { #deploy-your-app-optional }
Sie können optional Ihre FastAPI-App in der <a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a> deployen, treten Sie der Warteliste bei, falls Sie es noch nicht getan haben. 🚀
Wenn Sie bereits ein **FastAPI Cloud**-Konto haben (wir haben Sie von der Warteliste eingeladen 😉), können Sie Ihre Anwendung mit einem Befehl deployen.
Vor dem Deployen, stellen Sie sicher, dass Sie eingeloggt sind:
<div class="termy">
```console
$ fastapi login
You are logged in to FastAPI Cloud 🚀
```
</div>
Dann stellen Sie Ihre App bereit:
<div class="termy">
```console
$ fastapi deploy
Deploying to FastAPI Cloud...
✅ Deployment successful!
🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev
```
</div>
Das war's! Jetzt können Sie Ihre App unter dieser URL aufrufen. ✨
## Zusammenfassung, Schritt für Schritt { #recap-step-by-step }
### Schritt 1: `FastAPI` importieren { #step-1-import-fastapi }
@ -155,7 +191,7 @@ Ebenfalls können Sie es verwenden, um automatisch Code für Clients zu generier
`FastAPI` ist eine Klasse, die direkt von `Starlette` erbt.
Sie können alle <a href="https://www.starlette.io/" class="external-link" target="_blank">Starlette</a>-Funktionalitäten auch mit `FastAPI` nutzen.
Sie können alle <a href="https://www.starlette.dev/" class="external-link" target="_blank">Starlette</a>-Funktionalitäten auch mit `FastAPI` nutzen.
///
@ -314,6 +350,26 @@ Sie können auch Pydantic-Modelle zurückgeben (dazu später mehr).
Es gibt viele andere Objekte und Modelle, die automatisch zu JSON konvertiert werden (einschließlich ORMs, usw.). Versuchen Sie, Ihre Lieblingsobjekte zu verwenden. Es ist sehr wahrscheinlich, dass sie bereits unterstützt werden.
### Schritt 6: Deployen { #step-6-deploy-it }
Stellen Sie Ihre App in der **<a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>** mit einem Befehl bereit: `fastapi deploy`. 🎉
#### Über FastAPI Cloud { #about-fastapi-cloud }
**<a href="https://fastapicloud.com" class="external-link" target="_blank">FastAPI Cloud</a>** wird vom selben Autor und Team hinter **FastAPI** entwickelt.
Es vereinfacht den Prozess des Erstellens, Deployens und des Zugriffs auf eine API mit minimalem Aufwand.
Es bringt die gleiche **Developer-Experience** beim Erstellen von Apps mit FastAPI auch zum **Deployment** in der Cloud. 🎉
FastAPI Cloud ist der Hauptsponsor und Finanzierer der „FastAPI and friends“ Open-Source-Projekte. ✨
#### Zu anderen Cloudanbietern deployen { #deploy-to-other-cloud-providers }
FastAPI ist Open Source und basiert auf Standards. Sie können FastAPI-Apps bei jedem Cloudanbieter Ihrer Wahl deployen.
Folgen Sie den Anleitungen Ihres Cloudanbieters, um dort FastAPI-Apps bereitzustellen. 🤓
## Zusammenfassung { #recap }
* Importieren Sie `FastAPI`.
@ -321,3 +377,4 @@ Es gibt viele andere Objekte und Modelle, die automatisch zu JSON konvertiert we
* Schreiben Sie einen **Pfadoperation-Dekorator** unter Verwendung von Dekoratoren wie `@app.get("/")`.
* Definieren Sie eine **Pfadoperation-Funktion**, zum Beispiel `def root(): ...`.
* Starten Sie den Entwicklungsserver mit dem Befehl `fastapi dev`.
* Optional: Ihre App mit `fastapi deploy` deployen.

View File

@ -81,7 +81,7 @@ Aber falls Sie es für ein fortgeschrittenes Szenario benötigen, können Sie be
## Benutzerdefinierte Exceptionhandler installieren { #install-custom-exception-handlers }
Sie können benutzerdefinierte <abbr title="Ausnahmebehandler: Funktion, die sich um die Bearbeitung einer Exception kümmert">Exceptionhandler</abbr> mit <a href="https://www.starlette.io/exceptions/" class="external-link" target="_blank">den gleichen Exception-Werkzeugen von Starlette</a> hinzufügen.
Sie können benutzerdefinierte <abbr title="Ausnahmebehandler: Funktion, die sich um die Bearbeitung einer Exception kümmert">Exceptionhandler</abbr> mit <a href="https://www.starlette.dev/exceptions/" class="external-link" target="_blank">den gleichen Exception-Werkzeugen von Starlette</a> hinzufügen.
Angenommen, Sie haben eine benutzerdefinierte Exception `UnicornException`, die Sie (oder eine Bibliothek, die Sie verwenden) `raise`n könnten.
@ -127,7 +127,7 @@ Um diesen zu überschreiben, importieren Sie den `RequestValidationError` und ve
Der Exceptionhandler erhält einen `Request` und die Exception.
{* ../../docs_src/handling_errors/tutorial004.py hl[2,14:16] *}
{* ../../docs_src/handling_errors/tutorial004.py hl[2,14:19] *}
Wenn Sie nun zu `/items/foo` gehen, erhalten Sie anstelle des standardmäßigen JSON-Fehlers mit:
@ -149,36 +149,17 @@ Wenn Sie nun zu `/items/foo` gehen, erhalten Sie anstelle des standardmäßigen
eine Textversion mit:
```
1 validation error
path -> item_id
value is not a valid integer (type=type_error.integer)
Validation errors:
Field: ('path', 'item_id'), Error: Input should be a valid integer, unable to parse string as an integer
```
#### `RequestValidationError` vs. `ValidationError` { #requestvalidationerror-vs-validationerror }
/// warning | Achtung
Dies sind technische Details, die Sie überspringen können, wenn sie für Sie jetzt nicht wichtig sind.
///
`RequestValidationError` ist eine Unterklasse von Pydantics <a href="https://docs.pydantic.dev/latest/concepts/models/#error-handling" class="external-link" target="_blank">`ValidationError`</a>.
**FastAPI** verwendet diesen so, dass, wenn Sie ein Pydantic-Modell in `response_model` verwenden und Ihre Daten einen Fehler haben, Sie den Fehler in Ihrem Log sehen.
Aber der Client/Benutzer wird ihn nicht sehen. Stattdessen erhält der Client einen „Internal Server Error“ mit einem HTTP-Statuscode `500`.
Es sollte so sein, denn wenn Sie einen Pydantic `ValidationError` in Ihrer *Response* oder irgendwo anders in Ihrem Code haben (nicht im *Request* des Clients), ist es tatsächlich ein Fehler in Ihrem Code.
Und während Sie den Fehler beheben, sollten Ihre Clients/Benutzer keinen Zugriff auf interne Informationen über den Fehler haben, da das eine Sicherheitslücke aufdecken könnte.
### Überschreiben des `HTTPException`-Fehlerhandlers { #override-the-httpexception-error-handler }
Auf die gleiche Weise können Sie den `HTTPException`-Handler überschreiben.
Zum Beispiel könnten Sie eine Klartext-Response statt JSON für diese Fehler zurückgeben wollen:
{* ../../docs_src/handling_errors/tutorial004.py hl[3:4,9:11,22] *}
{* ../../docs_src/handling_errors/tutorial004.py hl[3:4,9:11,25] *}
/// note | Technische Details
@ -188,6 +169,14 @@ Sie könnten auch `from starlette.responses import PlainTextResponse` verwenden.
///
/// warning | Achtung
Beachten Sie, dass der `RequestValidationError` Informationen über den Dateinamen und die Zeile enthält, in der der Validierungsfehler auftritt, sodass Sie ihn bei Bedarf mit den relevanten Informationen in Ihren Logs anzeigen können.
Das bedeutet aber auch, dass, wenn Sie ihn einfach in einen String umwandeln und diese Informationen direkt zurückgeben, Sie möglicherweise ein paar Informationen über Ihr System preisgeben. Daher extrahiert und zeigt der Code hier jeden Fehler getrennt.
///
### Verwenden des `RequestValidationError`-Bodys { #use-the-requestvalidationerror-body }
Der `RequestValidationError` enthält den empfangenen `body` mit den ungültigen Daten.

View File

@ -37,7 +37,7 @@ Die Middleware-Funktion erhält:
Beachten Sie, dass benutzerdefinierte proprietäre Header hinzugefügt werden können <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">unter Verwendung des `X-`-Präfixes</a>.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen soll, müssen Sie sie zu Ihrer CORS-Konfiguration ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) hinzufügen, indem Sie den Parameter `expose_headers` verwenden, der in der <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlettes CORS-Dokumentation</a> dokumentiert ist.
Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser sehen soll, müssen Sie sie zu Ihrer CORS-Konfiguration ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) hinzufügen, indem Sie den Parameter `expose_headers` verwenden, der in der <a href="https://www.starlette.dev/middleware/#corsmiddleware" class="external-link" target="_blank">Starlettes CORS-Dokumentation</a> dokumentiert ist.
///

View File

@ -65,7 +65,7 @@ Es gibt ein paar Unterschiede:
* `Field(primary_key=True)` sagt SQLModel, dass die `id` der **Primärschlüssel** in der SQL-Datenbank ist (Sie können mehr über SQL-Primärschlüssel in der SQLModel-Dokumentation erfahren).
Durch das Festlegen des Typs als `int | None` wird SQLModel wissen, dass diese Spalte ein `INTEGER` in der SQL-Datenbank sein sollte und dass sie `NULLABLE` sein sollte.
**Hinweis:** Wir verwenden für das Primärschlüsselfeld `int | None`, damit wir im Python-Code *ein Objekt ohne `id` erstellen* können (`id=None`), in der Annahme, dass die Datenbank sie *beim Speichern generiert*. SQLModel versteht, dass die Datenbank die `id` bereitstellt, und *definiert die Spalte im Datenbankschema als ein Nicht-Null-`INTEGER`*. Siehe die <a href="https://sqlmodel.tiangolo.com/tutorial/create-db-and-table/#primary-key-id" class="external-link" target="_blank">SQLModel-Dokumentation zu Primärschlüsseln</a> für Details.
* `Field(index=True)` sagt SQLModel, dass es einen **SQL-Index** für diese Spalte erstellen soll, was schnelleres Suchen in der Datenbank ermöglicht, wenn Daten mittels dieser Spalte gefiltert werden.

View File

@ -37,4 +37,4 @@ Alle diese Parameter können anders als „`static`“ lauten, passen Sie sie an
## Weitere Informationen { #more-info }
Weitere Details und Optionen finden Sie in der <a href="https://www.starlette.io/staticfiles/" class="external-link" target="_blank">Dokumentation von Starlette zu statischen Dateien</a>.
Weitere Details und Optionen finden Sie in der <a href="https://www.starlette.dev/staticfiles/" class="external-link" target="_blank">Dokumentation von Starlette zu statischen Dateien</a>.

View File

@ -1,6 +1,6 @@
# Testen { #testing }
Dank <a href="https://www.starlette.io/testclient/" class="external-link" target="_blank">Starlette</a> ist das Testen von **FastAPI**-Anwendungen einfach und macht Spaß.
Dank <a href="https://www.starlette.dev/testclient/" class="external-link" target="_blank">Starlette</a> ist das Testen von **FastAPI**-Anwendungen einfach und macht Spaß.
Es basiert auf <a href="https://www.python-httpx.org" class="external-link" target="_blank">HTTPX</a>, welches wiederum auf der Grundlage von Requests konzipiert wurde, es ist also sehr vertraut und intuitiv.
@ -122,63 +122,13 @@ Sie verfügt über eine `POST`-Operation, die mehrere Fehler zurückgeben könnt
Beide *Pfadoperationen* erfordern einen `X-Token`-Header.
//// tab | Python 3.10+
```Python
{!> ../../docs_src/app_testing/app_b_an_py310/main.py!}
```
////
//// tab | Python 3.9+
```Python
{!> ../../docs_src/app_testing/app_b_an_py39/main.py!}
```
////
//// tab | Python 3.8+
```Python
{!> ../../docs_src/app_testing/app_b_an/main.py!}
```
////
//// tab | Python 3.10+ nicht annotiert
/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python
{!> ../../docs_src/app_testing/app_b_py310/main.py!}
```
////
//// tab | Python 3.8+ nicht annotiert
/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
///
```Python
{!> ../../docs_src/app_testing/app_b/main.py!}
```
////
{* ../../docs_src/app_testing/app_b_an_py310/main.py *}
### Erweiterte Testdatei { #extended-testing-file }
Anschließend könnten Sie `test_main.py` mit den erweiterten Tests aktualisieren:
{* ../../docs_src/app_testing/app_b/test_main.py *}
{* ../../docs_src/app_testing/app_b_an_py310/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

@ -242,6 +242,26 @@ $ python -m pip install --upgrade pip
</div>
/// tip | Tipp
Manchmal kann beim Versuch, `pip` zu aktualisieren, der Fehler **`No module named pip`** auftreten.
Wenn das passiert, installieren und aktualisieren Sie `pip` mit dem folgenden Befehl:
<div class="termy">
```console
$ python -m ensurepip --upgrade
---> 100%
```
</div>
Dieser Befehl installiert `pip`, falls es noch nicht installiert ist, und stellt außerdem sicher, dass die installierte Version von `pip` mindestens so aktuell ist wie die in `ensurepip` verfügbare.
///
## `.gitignore` hinzufügen { #add-gitignore }
Wenn Sie **Git** verwenden (was Sie sollten), fügen Sie eine `.gitignore`-Datei hinzu, um alles in Ihrem `.venv` von Git auszuschließen.

View File

@ -185,7 +185,7 @@ Example:
# FastAPI in Containern - Docker { #fastapi-in-containers-docker }
»»»
3.1) Do not apply rule 3 when there is no space before or no space after the dash.
3.1) Do not apply rule 3 when there is no space before or no space after the hyphen.
Example:
@ -195,13 +195,13 @@ Example:
## Type hints and annotations { #type-hints-and-annotations }
»»»
Translate with (German) use a short dash:
Translate with (German) notice the hyphen:
«««
## Typhinweise und -annotationen { #type-hints-and-annotations }
»»»
Do NOT translate with (German):
Do NOT translate with (German) notice the dash:
«««
## Typhinweise und annotationen { #type-hints-and-annotations }
@ -222,7 +222,7 @@ Ich versuche nicht, alles einzudeutschen. Das bezieht sich besonders auf Begriff
### List of English terms and their preferred German translations
Below is a list of English terms and their preferred German translations, separated by a colon («:»). Use these translations, do not use your own. If an existing translation does not use these terms, update it to use them. A term or a translation may be followed by an explanation in brackets, which explains when to translate the term this way. If a translation is preceded by «NOT», then that means: do NOT use this translation for this term. English nouns, starting with the word «the», have the German genus «der», «die», «das» prepended to their German translation, to help you to grammatically decline them in the translation. They are given in singular case, unless they have «(plural)» attached, which means they are given in plural case. Verbs are given in the full infinitive starting with the word «to».
Below is a list of English terms and their preferred German translations, separated by a colon («:»). Use these translations, do not use your own. If an existing translation does not use these terms, update it to use them. In the below list, a term or a translation may be followed by an explanation in brackets, which explains when to translate the term this way. If a translation is preceded by «NOT», then that means: do NOT use this translation for this term. English nouns, starting with the word «the», have the German genus «der», «die», «das» prepended to their German translation, to help you to grammatically decline them in the translation. They are given in singular case, unless they have «(plural)» attached, which means they are given in plural case. Verbs are given in the full infinitive starting with the word «to».
* «/// check»: «/// check | Testen»
* «/// danger»: «/// danger | Gefahr»
@ -255,6 +255,7 @@ Below is a list of English terms and their preferred German translations, separa
* «the default value»: «der Defaultwert»
* «the default value»: NOT «der Standardwert»
* «the default declaration»: «die Default-Deklaration»
* «the deployment»: «das Deployment»
* «the dict»: «das Dict»
* «the dictionary»: «das Dictionary»
* «the enumeration»: «die Enumeration»
@ -316,6 +317,7 @@ Below is a list of English terms and their preferred German translations, separa
* «the worker process»: «der Workerprozess»
* «the worker process»: NOT «der Arbeiterprozess»
* «to commit»: «committen»
* «to deploy» (in the cloud): «deployen»
* «to modify»: «ändern»
* «to serve» (an application): «bereitstellen»
* «to serve» (a response): «ausliefern»

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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