From 66abaa781ea203fff469f8f498e0bbff90316630 Mon Sep 17 00:00:00 2001 From: hasansezertasan Date: Tue, 21 May 2024 00:15:52 +0300 Subject: [PATCH 1/4] copies original file as is, with no translation --- docs/tr/docs/advanced/response-cookies.md | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docs/tr/docs/advanced/response-cookies.md diff --git a/docs/tr/docs/advanced/response-cookies.md b/docs/tr/docs/advanced/response-cookies.md new file mode 100644 index 000000000..d53985dbb --- /dev/null +++ b/docs/tr/docs/advanced/response-cookies.md @@ -0,0 +1,49 @@ +# Response Cookies + +## Use a `Response` parameter + +You can declare a parameter of type `Response` in your *path operation function*. + +And then you can set cookies in that *temporal* response object. + +```Python hl_lines="1 8-9" +{!../../../docs_src/response_cookies/tutorial002.py!} +``` + +And then you can return any object you need, as you normally would (a `dict`, a database model, etc). + +And if you declared a `response_model`, it will still be used to filter and convert the object you returned. + +**FastAPI** will use that *temporal* response to extract the cookies (also headers and status code), and will put them in the final response that contains the value you returned, filtered by any `response_model`. + +You can also declare the `Response` parameter in dependencies, and set cookies (and headers) in them. + +## Return a `Response` directly + +You can also create cookies when returning a `Response` directly in your code. + +To do that, you can create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank}. + +Then set Cookies in it, and then return it: + +```Python hl_lines="10-12" +{!../../../docs_src/response_cookies/tutorial001.py!} +``` + +!!! tip + Keep in mind that if you return a response directly instead of using the `Response` parameter, FastAPI will return it directly. + + So, you will have to make sure your data is of the correct type. E.g. it is compatible with JSON, if you are returning a `JSONResponse`. + + And also that you are not sending any data that should have been filtered by a `response_model`. + +### More info + +!!! note "Technical Details" + You could also use `from starlette.responses import Response` or `from starlette.responses import JSONResponse`. + + **FastAPI** provides the same `starlette.responses` as `fastapi.responses` just as a convenience for you, the developer. But most of the available responses come directly from Starlette. + + And as the `Response` can be used frequently to set headers and cookies, **FastAPI** also provides it at `fastapi.Response`. + +To see all the available parameters and options, check the documentation in Starlette. From cbe439aa1a71e7a4ccefcd511142c79c8cd9b328 Mon Sep 17 00:00:00 2001 From: hasansezertasan Date: Tue, 21 May 2024 00:32:51 +0300 Subject: [PATCH 2/4] Translation completed, ready tp PR. --- docs/tr/docs/advanced/response-cookies.md | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/tr/docs/advanced/response-cookies.md b/docs/tr/docs/advanced/response-cookies.md index d53985dbb..062d10876 100644 --- a/docs/tr/docs/advanced/response-cookies.md +++ b/docs/tr/docs/advanced/response-cookies.md @@ -1,49 +1,49 @@ -# Response Cookies +# Yanıt Çerezleri -## Use a `Response` parameter +## Bir `Response` Parametresi Kullanın -You can declare a parameter of type `Response` in your *path operation function*. +*yol operasyonu fonksiyonunuzda* `Response` türünde bir parametre belirleyebilirsiniz. -And then you can set cookies in that *temporal* response object. +Ardından *geçici* yanıt nesnesinde çerezleri belirleyebilirsiniz. ```Python hl_lines="1 8-9" {!../../../docs_src/response_cookies/tutorial002.py!} ``` -And then you can return any object you need, as you normally would (a `dict`, a database model, etc). +Sonunda normalde döndürdüğünüz gibi herhangi bir nesneyi döndürebilirsiniz (bir `dict`, bir veritabanı modeli, vb). -And if you declared a `response_model`, it will still be used to filter and convert the object you returned. +Eğer bir `response_model` belirlediyseniz, döndürdüğünüz nesneyi filtrelemek ve dönüştürmek için kullanılacaktır. -**FastAPI** will use that *temporal* response to extract the cookies (also headers and status code), and will put them in the final response that contains the value you returned, filtered by any `response_model`. +**FastAPI** bu *geçici* yanıtı çerezleri (ayrıca durum kodunu ve başlıkları) çıkarmak için kullanacak ve döndürdüğünüz değeri herhangi bir `response_model` tarafından filtreleyerek son yanıta koyacaktır. -You can also declare the `Response` parameter in dependencies, and set cookies (and headers) in them. +Bağımlılıklarda da `Response` parametresini belirtebilir ve çezerlezi belirleyebilirsiniz. -## Return a `Response` directly +## Bir `Response`'u Doğrudan Döndürün -You can also create cookies when returning a `Response` directly in your code. +Doğrudan bir `Response` döndürürken çerezler oluşturabilirsiniz. -To do that, you can create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank}. +Bunun için [Return a Response Directly](response-directly.md){.internal-link target=_blank} sayfasında açıklandığı gibi bir yanıt oluşturabilirsiniz. -Then set Cookies in it, and then return it: +Ardından çerezleri belirleyin ve yanıtı döndürün: ```Python hl_lines="10-12" {!../../../docs_src/response_cookies/tutorial001.py!} ``` -!!! tip - Keep in mind that if you return a response directly instead of using the `Response` parameter, FastAPI will return it directly. +!!! tip "İpucu" + `Response` parametresini kullanmak yerine yanıtı doğrudan döndürürseniz, FastAPI yanıtı doğrudan döndürecektir. - So, you will have to make sure your data is of the correct type. E.g. it is compatible with JSON, if you are returning a `JSONResponse`. + Yanıtı doğrudan döndürürken, verinizin doğru türde olduğundan emin olmalısınız. Örneğin, bir `JSONResponse` döndürüyorsanız, verinizin JSON ile uyumlu olduğundan emin olmalısınız. - And also that you are not sending any data that should have been filtered by a `response_model`. + Ayrıca, bir `response_model` tarafından filtrelenmesi gereken verileri göndermediğinizden emin olmalısınız. -### More info +## Daha Fazla Bilgi -!!! note "Technical Details" - You could also use `from starlette.responses import Response` or `from starlette.responses import JSONResponse`. +!!! note "Teknik Detaylar" + Projenize dahil etmek için `from starlette.responses import Response` veya `from starlette.responses import JSONResponse` kullanabilirsiniz. - **FastAPI** provides the same `starlette.responses` as `fastapi.responses` just as a convenience for you, the developer. But most of the available responses come directly from Starlette. + **FastAPI**, geliştiricilere kolaylık sağlamak amacıyla `starlette.responses`'ı `fastapi.responses` olarak sağlar. Ancak mevcut yanıtların çoğu doğrudan Starlette'den gelir. Aynı durum `status` için de geçerlidir. - And as the `Response` can be used frequently to set headers and cookies, **FastAPI** also provides it at `fastapi.Response`. + `Response` sıklıkla başlıkları ve çerezleri belirlemek için kullanılabileceği için, **FastAPI** ayrıca `fastapi.Response`'ı da sağlar. -To see all the available parameters and options, check the documentation in Starlette. +Tüm mevcut parametreleri ve seçenekleri görmek için Starlette dokümantasyonunu incelleyin. From e8969299e115bf6550beaa499d082ebb6f2ec6d5 Mon Sep 17 00:00:00 2001 From: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:15:19 +0200 Subject: [PATCH 3/4] Apply suggestions from code review --- docs/tr/docs/advanced/response-cookies.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/tr/docs/advanced/response-cookies.md b/docs/tr/docs/advanced/response-cookies.md index 062d10876..2bd625925 100644 --- a/docs/tr/docs/advanced/response-cookies.md +++ b/docs/tr/docs/advanced/response-cookies.md @@ -6,9 +6,7 @@ Ardından *geçici* yanıt nesnesinde çerezleri belirleyebilirsiniz. -```Python hl_lines="1 8-9" -{!../../../docs_src/response_cookies/tutorial002.py!} -``` +{* ../../docs_src/response_cookies/tutorial002.py hl[1, 8:9] *} Sonunda normalde döndürdüğünüz gibi herhangi bir nesneyi döndürebilirsiniz (bir `dict`, bir veritabanı modeli, vb). @@ -26,16 +24,15 @@ Bunun için [Return a Response Directly](response-directly.md){.internal-link ta Ardından çerezleri belirleyin ve yanıtı döndürün: -```Python hl_lines="10-12" -{!../../../docs_src/response_cookies/tutorial001.py!} -``` +{* ../../docs_src/response_cookies/tutorial001.py hl[10:12] *} -!!! tip "İpucu" +/// tip | İpucu `Response` parametresini kullanmak yerine yanıtı doğrudan döndürürseniz, FastAPI yanıtı doğrudan döndürecektir. Yanıtı doğrudan döndürürken, verinizin doğru türde olduğundan emin olmalısınız. Örneğin, bir `JSONResponse` döndürüyorsanız, verinizin JSON ile uyumlu olduğundan emin olmalısınız. Ayrıca, bir `response_model` tarafından filtrelenmesi gereken verileri göndermediğinizden emin olmalısınız. +/// ## Daha Fazla Bilgi From ef7938cc56afddb885ff1230f3eb9b58c294e042 Mon Sep 17 00:00:00 2001 From: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:43:58 +0200 Subject: [PATCH 4/4] Update response-cookies.md --- docs/tr/docs/advanced/response-cookies.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/tr/docs/advanced/response-cookies.md b/docs/tr/docs/advanced/response-cookies.md index 2bd625925..03dc57024 100644 --- a/docs/tr/docs/advanced/response-cookies.md +++ b/docs/tr/docs/advanced/response-cookies.md @@ -27,20 +27,25 @@ Ardından çerezleri belirleyin ve yanıtı döndürün: {* ../../docs_src/response_cookies/tutorial001.py hl[10:12] *} /// tip | İpucu - `Response` parametresini kullanmak yerine yanıtı doğrudan döndürürseniz, FastAPI yanıtı doğrudan döndürecektir. - Yanıtı doğrudan döndürürken, verinizin doğru türde olduğundan emin olmalısınız. Örneğin, bir `JSONResponse` döndürüyorsanız, verinizin JSON ile uyumlu olduğundan emin olmalısınız. +`Response` parametresini kullanmak yerine yanıtı doğrudan döndürürseniz, FastAPI yanıtı doğrudan döndürecektir. + +Yanıtı doğrudan döndürürken, verinizin doğru türde olduğundan emin olmalısınız. Örneğin, bir `JSONResponse` döndürüyorsanız, verinizin JSON ile uyumlu olduğundan emin olmalısınız. + +Ayrıca, bir `response_model` tarafından filtrelenmesi gereken verileri göndermediğinizden emin olmalısınız. - Ayrıca, bir `response_model` tarafından filtrelenmesi gereken verileri göndermediğinizden emin olmalısınız. /// ## Daha Fazla Bilgi -!!! note "Teknik Detaylar" - Projenize dahil etmek için `from starlette.responses import Response` veya `from starlette.responses import JSONResponse` kullanabilirsiniz. +/// note | Teknik Detaylar + +Projenize dahil etmek için `from starlette.responses import Response` veya `from starlette.responses import JSONResponse` kullanabilirsiniz. - **FastAPI**, geliştiricilere kolaylık sağlamak amacıyla `starlette.responses`'ı `fastapi.responses` olarak sağlar. Ancak mevcut yanıtların çoğu doğrudan Starlette'den gelir. Aynı durum `status` için de geçerlidir. +**FastAPI**, geliştiricilere kolaylık sağlamak amacıyla `starlette.responses`'ı `fastapi.responses` olarak sağlar. Ancak mevcut yanıtların çoğu doğrudan Starlette'den gelir. Aynı durum `status` için de geçerlidir. - `Response` sıklıkla başlıkları ve çerezleri belirlemek için kullanılabileceği için, **FastAPI** ayrıca `fastapi.Response`'ı da sağlar. +`Response` sıklıkla başlıkları ve çerezleri belirlemek için kullanılabileceği için, **FastAPI** ayrıca `fastapi.Response`'ı da sağlar. + +/// Tüm mevcut parametreleri ve seçenekleri görmek için Starlette dokümantasyonunu incelleyin.