Browse Source

Merge branch 'tiangolo:master' into tr/advanced/response-change-status-code.md

pull/11612/head
Hasan Sezer Taşan 10 months ago
committed by GitHub
parent
commit
9f5b15f402
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      README.md
  2. 3
      docs/en/data/sponsors.yml
  3. BIN
      docs/en/docs/img/sponsors/kong-banner.png
  4. BIN
      docs/en/docs/img/sponsors/kong.png
  5. 2
      docs/en/docs/python-types.md
  6. 7
      docs/en/docs/release-notes.md
  7. 8
      docs/en/docs/tutorial/query-params-str-validations.md
  8. 6
      docs/en/overrides/main.html
  9. 16
      docs/tr/docs/advanced/security/index.md
  10. 12
      docs/tr/docs/advanced/testing-websockets.md
  11. 17
      docs/tr/docs/deployment/cloud.md
  12. 39
      docs/tr/docs/how-to/general.md
  13. 71
      docs/zh/docs/advanced/templates.md

1
README.md

@ -55,6 +55,7 @@ The key features are:
<a href="https://www.propelauth.com/?utm_source=fastapi&utm_campaign=1223&utm_medium=mainbadge" target="_blank" title="Auth, user management and more for your B2B product"><img src="https://fastapi.tiangolo.com/img/sponsors/propelauth.png"></a>
<a href="https://www.withcoherence.com/?utm_medium=advertising&utm_source=fastapi&utm_campaign=banner%20january%2024" target="_blank" title="Coherence"><img src="https://fastapi.tiangolo.com/img/sponsors/coherence.png"></a>
<a href="https://www.mongodb.com/developer/languages/python/python-quickstart-fastapi/?utm_campaign=fastapi_framework&utm_source=fastapi_sponsorship&utm_medium=web_referral" target="_blank" title="Simplify Full Stack Development with FastAPI & MongoDB"><img src="https://fastapi.tiangolo.com/img/sponsors/mongodb.png"></a>
<a href="https://konghq.com/products/kong-konnect/register?utm_medium=referral&utm_source=github&utm_campaign=platform&utm_content=fast-api" target="_blank" title="Kong Konnect - API management platform"><img src="https://fastapi.tiangolo.com/img/sponsors/kong.png"></a>
<a href="https://training.talkpython.fm/fastapi-courses" target="_blank" title="FastAPI video courses on demand from people you trust"><img src="https://fastapi.tiangolo.com/img/sponsors/talkpython-v2.jpg"></a>
<a href="https://github.com/deepset-ai/haystack/" target="_blank" title="Build powerful search from composable, open source building blocks"><img src="https://fastapi.tiangolo.com/img/sponsors/haystack-fastapi.svg"></a>
<a href="https://databento.com/" target="_blank" title="Pay as you go for market data"><img src="https://fastapi.tiangolo.com/img/sponsors/databento.svg"></a>

3
docs/en/data/sponsors.yml

@ -26,6 +26,9 @@ gold:
- url: https://www.mongodb.com/developer/languages/python/python-quickstart-fastapi/?utm_campaign=fastapi_framework&utm_source=fastapi_sponsorship&utm_medium=web_referral
title: Simplify Full Stack Development with FastAPI & MongoDB
img: https://fastapi.tiangolo.com/img/sponsors/mongodb.png
- url: https://konghq.com/products/kong-konnect/register?utm_medium=referral&utm_source=github&utm_campaign=platform&utm_content=fast-api
title: Kong Konnect - API management platform
img: https://fastapi.tiangolo.com/img/sponsors/kong.png
silver:
- url: https://training.talkpython.fm/fastapi-courses
title: FastAPI video courses on demand from people you trust

BIN
docs/en/docs/img/sponsors/kong-banner.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/en/docs/img/sponsors/kong.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

2
docs/en/docs/python-types.md

@ -476,7 +476,7 @@ You will see a lot more of all this in practice in the [Tutorial - User Guide](t
## Type Hints with Metadata Annotations
Python also has a feature that allows putting **additional metadata** in these type hints using `Annotated`.
Python also has a feature that allows putting **additional <abbr title="Data about the data, in this case, information about the type, e.g. a description.">metadata</abbr>** in these type hints using `Annotated`.
=== "Python 3.9+"

7
docs/en/docs/release-notes.md

@ -15,6 +15,7 @@ hide:
### Docs
* 📝 Tweak intro docs about `Annotated` and `Query()` params. PR [#11664](https://github.com/tiangolo/fastapi/pull/11664) by [@tiangolo](https://github.com/tiangolo).
* 📝 Update JWT auth documentation to use PyJWT instead of pyhon-jose. PR [#11589](https://github.com/tiangolo/fastapi/pull/11589) by [@estebanx64](https://github.com/estebanx64).
* 📝 Update docs. PR [#11603](https://github.com/tiangolo/fastapi/pull/11603) by [@alejsdev](https://github.com/alejsdev).
* ✏️ Fix typo: convert every 're-use' to 'reuse'.. PR [#11598](https://github.com/tiangolo/fastapi/pull/11598) by [@hasansezertasan](https://github.com/hasansezertasan).
@ -23,6 +24,11 @@ hide:
### Translations
* 🌐 Add Turkish translation for `docs/tr/docs/deployment/cloud.md`. PR [#11610](https://github.com/tiangolo/fastapi/pull/11610) by [@hasansezertasan](https://github.com/hasansezertasan).
* 🌐 Add Turkish translation for `docs/tr/docs/advanced/security/index.md`. PR [#11609](https://github.com/tiangolo/fastapi/pull/11609) by [@hasansezertasan](https://github.com/hasansezertasan).
* 🌐 Add Turkish translation for `docs/tr/docs/advanced/testing-websockets.md`. PR [#11608](https://github.com/tiangolo/fastapi/pull/11608) by [@hasansezertasan](https://github.com/hasansezertasan).
* 🌐 Add Turkish translation for `docs/tr/docs/how-to/general.md`. PR [#11607](https://github.com/tiangolo/fastapi/pull/11607) by [@hasansezertasan](https://github.com/hasansezertasan).
* 🌐 Update Chinese translation for `docs/zh/docs/advanced/templates.md`. PR [#11620](https://github.com/tiangolo/fastapi/pull/11620) by [@chaoless](https://github.com/chaoless).
* 🌐 Add Turkish translation for `docs/tr/docs/deployment/index.md`. PR [#11605](https://github.com/tiangolo/fastapi/pull/11605) by [@hasansezertasan](https://github.com/hasansezertasan).
* 🌐 Add Turkish translation for `docs/tr/docs/tutorial/static-files.md`. PR [#11599](https://github.com/tiangolo/fastapi/pull/11599) by [@hasansezertasan](https://github.com/hasansezertasan).
* 🌐 Polish translation for `docs/pl/docs/fastapi-people.md`. PR [#10196](https://github.com/tiangolo/fastapi/pull/10196) by [@isulim](https://github.com/isulim).
@ -35,6 +41,7 @@ hide:
### Internal
* 🔧 Add sponsor Kong. PR [#11662](https://github.com/tiangolo/fastapi/pull/11662) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update Smokeshow, fix sync download artifact and smokeshow configs. PR [#11563](https://github.com/tiangolo/fastapi/pull/11563) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update Smokeshow download artifact GitHub Action. PR [#11562](https://github.com/tiangolo/fastapi/pull/11562) by [@tiangolo](https://github.com/tiangolo).
* 👷 Update GitHub actions to download and upload artifacts to v4, for docs and coverage. PR [#11550](https://github.com/tiangolo/fastapi/pull/11550) by [@tamird](https://github.com/tamird).

8
docs/en/docs/tutorial/query-params-str-validations.md

@ -99,7 +99,7 @@ Now let's jump to the fun stuff. 🎉
## Add `Query` to `Annotated` in the `q` parameter
Now that we have this `Annotated` where we can put more metadata, add `Query` to it, and set the parameter `max_length` to 50:
Now that we have this `Annotated` where we can put more information (in this case some additional validation), add `Query` inside of `Annotated`, and set the parameter `max_length` to `50`:
=== "Python 3.10+"
@ -115,7 +115,11 @@ Now that we have this `Annotated` where we can put more metadata, add `Query` to
Notice that the default value is still `None`, so the parameter is still optional.
But now, having `Query(max_length=50)` inside of `Annotated`, we are telling FastAPI that we want it to extract this value from the query parameters (this would have been the default anyway 🤷) and that we want to have **additional validation** for this value (that's why we do this, to get the additional validation). 😎
But now, having `Query(max_length=50)` inside of `Annotated`, we are telling FastAPI that we want it to have **additional validation** for this value, we want it to have maximum 50 characters. 😎
!!! tip
Here we are using `Query()` because this is a **query parameter**. Later we will see others like `Path()`, `Body()`, `Header()`, and `Cookie()`, that also accept the same arguments as `Query()`.
FastAPI will now:

6
docs/en/overrides/main.html

@ -76,6 +76,12 @@
<img class="sponsor-image" src="/img/sponsors/mongodb-banner.png" />
</a>
</div>
<div class="item">
<a title="Kong Konnect - API management platform" style="display: block; position: relative;" href="https://konghq.com/products/kong-konnect/register?utm_medium=referral&utm_source=github&utm_campaign=platform&utm_content=fast-api" target="_blank">
<span class="sponsor-badge">sponsor</span>
<img class="sponsor-image" src="/img/sponsors/kong-banner.png" />
</a>
</div>
</div>
</div>
{% endblock %}

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

@ -0,0 +1,16 @@
# Gelişmiş Güvenlik
## Ek Özellikler
[Tutorial - User Guide: Security](../../tutorial/security/index.md){.internal-link target=_blank} sayfasında ele alınanların dışında güvenlikle ilgili bazı ek özellikler vardır.
!!! tip "İpucu"
Sonraki bölümler **mutlaka "gelişmiş" olmak zorunda değildir**.
Kullanım şeklinize bağlı olarak, çözümünüz bu bölümlerden birinde olabilir.
## Önce Öğreticiyi Okuyun
Sonraki bölümler [Tutorial - User Guide: Security](../../tutorial/security/index.md){.internal-link target=_blank} sayfasını okuduğunuzu varsayarak hazırlanmıştır.
Bu bölümler aynı kavramlara dayanır, ancak bazı ek işlevsellikler sağlar.

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

@ -0,0 +1,12 @@
# WebSockets'i Test Etmek
WebSockets testi yapmak için `TestClient`'ı kullanabilirsiniz.
Bu işlem için, `TestClient`'ı bir `with` ifadesinde kullanarak WebSocket'e bağlanabilirsiniz:
```Python hl_lines="27-31"
{!../../../docs_src/app_testing/tutorial002.py!}
```
!!! note "Not"
Daha fazla detay için Starlette'in <a href="https://www.starlette.io/staticfiles/" class="external-link" target="_blank">Websockets'i Test Etmek</a> dokümantasyonunu inceleyin.

17
docs/tr/docs/deployment/cloud.md

@ -0,0 +1,17 @@
# FastAPI Uygulamasını Bulut Sağlayıcılar Üzerinde Yayınlama
FastAPI uygulamasını yayınlamak için hemen hemen **herhangi bir bulut sağlayıcıyı** kullanabilirsiniz.
Büyük bulut sağlayıcıların çoğu FastAPI uygulamasını yayınlamak için kılavuzlara sahiptir.
## Bulut Sağlayıcılar - Sponsorlar
Bazı bulut sağlayıcılar ✨ [**FastAPI destekçileridir**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨, bu FastAPI ve **ekosisteminin** sürekli ve sağlıklı bir şekilde **gelişmesini** sağlar.
Ayrıca, size **iyi servisler** sağlamakla kalmayıp, **iyi ve sağlıklı bir framework** olan FastAPI'a bağlılıklarını gösterir.
Bu hizmetleri denemek ve kılavuzlarını incelemek isteyebilirsiniz:
* <a href="https://docs.platform.sh/languages/python.html?utm_source=fastapi-signup&utm_medium=banner&utm_campaign=FastAPI-signup-June-2023" class="external-link" target="_blank">Platform.sh</a>
* <a href="https://docs.porter.run/language-specific-guides/fastapi" class="external-link" target="_blank">Porter</a>
* <a href="https://docs.withcoherence.com/docs/configuration/frameworks?utm_medium=advertising&utm_source=fastapi&utm_campaign=banner%20january%2024#fast-api-example" class="external-link" target="_blank">Coherence</a>

39
docs/tr/docs/how-to/general.md

@ -0,0 +1,39 @@
# Genel - Nasıl Yapılır - Tarifler
Bu sayfada genel ve sıkça sorulan sorular için dokümantasyonun diğer sayfalarına yönlendirmeler bulunmaktadır.
## Veri Filtreleme - Güvenlik
Döndürmeniz gereken veriden fazlasını döndürmediğinizden emin olmak için, [Tutorial - Response Model - Return Type](../tutorial/response-model.md){.internal-link target=_blank} sayfasını okuyun.
## Dokümantasyon Etiketleri - OpenAPI
*Yol operasyonlarınıza* etiketler ekleyerek dokümantasyon arayüzünde gruplar halinde görünmesini sağlamak için, [Tutorial - Path Operation Configurations - Tags](../tutorial/path-operation-configuration.md#tags){.internal-link target=_blank} sayfasını okuyun.
## Dokümantasyon Özeti ve Açıklaması - OpenAPI
*Yol operasyonlarınıza* özet ve açıklama ekleyip dokümantasyon arayüzünde görünmesini sağlamak için, [Tutorial - Path Operation Configurations - Summary and Description](../tutorial/path-operation-configuration.md#summary-and-description){.internal-link target=_blank} sayfasını okuyun.
## Yanıt Açıklaması Dokümantasyonu - OpenAPI
Dokümantasyon arayüzünde yer alan yanıt açıklamasını tanımlamak için, [Tutorial - Path Operation Configurations - Response description](../tutorial/path-operation-configuration.md#response-description){.internal-link target=_blank} sayfasını okuyun.
## *Yol Operasyonunu* Kullanımdan Kaldırma - OpenAPI
Bir *yol işlemi*ni kullanımdan kaldırmak ve bunu dokümantasyon arayüzünde göstermek için, [Tutorial - Path Operation Configurations - Deprecation](../tutorial/path-operation-configuration.md#deprecate-a-path-operation){.internal-link target=_blank} sayfasını okuyun.
## Herhangi Bir Veriyi JSON Uyumlu Hale Getirme
Herhangi bir veriyi JSON uyumlu hale getirmek için, [Tutorial - JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank} sayfasını okuyun.
## OpenAPI Meta Verileri - Dokümantasyon
OpenAPI şemanıza lisans, sürüm, iletişim vb. meta veriler eklemek için, [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md){.internal-link target=_blank} sayfasını okuyun.
## OpenAPI Bağlantı Özelleştirme
OpenAPI bağlantısını özelleştirmek (veya kaldırmak) için, [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#openapi-url){.internal-link target=_blank} sayfasını okuyun.
## OpenAPI Dokümantasyon Bağlantıları
Dokümantasyonu arayüzünde kullanılan bağlantıları güncellemek için, [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#docs-urls){.internal-link target=_blank} sayfasını okuyun.

71
docs/zh/docs/advanced/templates.md

@ -20,24 +20,12 @@ $ pip install jinja2
</div>
如需使用静态文件,还要安装 `aiofiles`
<div class="termy">
```console
$ pip install aiofiles
---> 100%
```
</div>
## 使用 `Jinja2Templates`
* 导入 `Jinja2Templates`
* 创建可复用的 `templates` 对象
* 在返回模板的*路径操作*中声明 `Request` 参数
* 使用 `templates` 渲染并返回 `TemplateResponse`以键值对方式在 Jinja2 的 **context** 中传递 `request`
* 使用 `templates` 渲染并返回 `TemplateResponse`, 传递模板的名称、request对象以及一个包含多个键值对(用于Jinja2模板)的"context"字典,
```Python hl_lines="4 11 15-16"
{!../../../docs_src/templates/tutorial001.py!}
@ -45,7 +33,8 @@ $ pip install aiofiles
!!! note "笔记"
注意,必须为 Jinja2 以键值对方式在上下文中传递 `request`。因此,还要在*路径操作*中声明。
在FastAPI 0.108.0,Starlette 0.29.0之前,`name`是第一个参数。
并且,在此之前,`request`对象是作为context的一部分以键值对的形式传递的。
!!! tip "提示"
@ -65,30 +54,68 @@ $ pip install aiofiles
{!../../../docs_src/templates/templates/item.html!}
```
它会显示从 **context** 字典中提取的 `id`
### 模板上下文
在包含如下语句的html中:
{% raw %}
```jinja
Item ID: {{ id }}
```
{% endraw %}
...这将显示你从"context"字典传递的 `id`:
```Python
{"request": request, "id": id}
{"id": id}
```
例如。当ID为 `42`时, 会渲染成:
```html
Item ID: 42
```
### 模板 `url_for` 参数
你还可以在模板内使用 `url_for()`,其参数与*路径操作函数*的参数相同.
所以,该部分:
{% raw %}
```jinja
<a href="{{ url_for('read_item', id=id) }}">
```
{% endraw %}
...将生成一个与处理*路径操作函数* `read_item(id=id)`的URL相同的链接
例如。当ID为 `42`时, 会渲染成:
```html
<a href="/items/42">
```
## 模板与静态文件
在模板内部使用 `url_for()`,例如,与挂载的 `StaticFiles` 一起使用。
你还可以在模板内部将 `url_for()`用于静态文件,例如你挂载的 `name="static"``StaticFiles`
```jinja hl_lines="4"
{!../../../docs_src/templates/templates/item.html!}
```
本例中,使用 `url_for()` 为模板添加 CSS 文件 `static/styles.css` 链接:
本例中,它将链接到 `static/styles.css`中的CSS文件
```CSS hl_lines="4"
{!../../../docs_src/templates/static/styles.css!}
```
因为使用了 `StaticFiles`**FastAPI** 应用自动提供位于 URL `/static/styles.css`
的 CSS 文件。
因为使用了 `StaticFiles`**FastAPI** 应用会自动提供位于 URL `/static/styles.css`的 CSS 文件。
## 更多说明
包括测试模板等更多详情,请参阅 <a href="https://www.starlette.io/templates/" class="external-link" target="_blank">Starlette 官档 - 模板</a>
包括测试模板等更多详情,请参阅 <a href="https://www.starlette.io/templates/" class="external-link" target="_blank">Starlette 官方文档 - 模板</a>

Loading…
Cancel
Save