mirror of https://github.com/tiangolo/fastapi.git
🌐 Update translations for tr (update-outdated) (#14831)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
8488d31aff
commit
da9e101d50
|
|
@ -1,18 +1,34 @@
|
||||||
# WSGI'yi Dahil Etme - Flask, Django ve Diğerleri { #including-wsgi-flask-django-others }
|
# WSGI'yi Dahil Etme - Flask, Django ve Diğerleri { #including-wsgi-flask-django-others }
|
||||||
|
|
||||||
WSGI uygulamalarını [Sub Applications - Mounts](sub-applications.md){.internal-link target=_blank}, [Behind a Proxy](behind-a-proxy.md){.internal-link target=_blank} bölümlerinde gördüğünüz gibi mount edebilirsiniz.
|
WSGI uygulamalarını [Alt Uygulamalar - Mount Etme](sub-applications.md){.internal-link target=_blank}, [Bir Proxy Arkasında](behind-a-proxy.md){.internal-link target=_blank} bölümlerinde gördüğünüz gibi mount edebilirsiniz.
|
||||||
|
|
||||||
Bunun için `WSGIMiddleware`'ı kullanabilir ve bunu WSGI uygulamanızı (örneğin Flask, Django vb.) sarmalamak için kullanabilirsiniz.
|
Bunun için `WSGIMiddleware`'ı kullanabilir ve bunu WSGI uygulamanızı (örneğin Flask, Django vb.) sarmalamak için kullanabilirsiniz.
|
||||||
|
|
||||||
## `WSGIMiddleware` Kullanımı { #using-wsgimiddleware }
|
## `WSGIMiddleware` Kullanımı { #using-wsgimiddleware }
|
||||||
|
|
||||||
`WSGIMiddleware`'ı import etmeniz gerekir.
|
/// info | Bilgi
|
||||||
|
|
||||||
|
Bunun için `a2wsgi` kurulmalıdır; örneğin `pip install a2wsgi` ile.
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
|
`WSGIMiddleware`'ı `a2wsgi` paketinden import etmeniz gerekir.
|
||||||
|
|
||||||
Ardından WSGI (örn. Flask) uygulamasını middleware ile sarmalayın.
|
Ardından WSGI (örn. Flask) uygulamasını middleware ile sarmalayın.
|
||||||
|
|
||||||
Ve sonra bunu bir path'in altına mount edin.
|
Ve sonra bunu bir path'in altına mount edin.
|
||||||
|
|
||||||
{* ../../docs_src/wsgi/tutorial001_py39.py hl[2:3,3] *}
|
{* ../../docs_src/wsgi/tutorial001_py39.py hl[1,3,23] *}
|
||||||
|
|
||||||
|
/// note | Not
|
||||||
|
|
||||||
|
Önceden, `fastapi.middleware.wsgi` içindeki `WSGIMiddleware`'ın kullanılması öneriliyordu, ancak artık kullanımdan kaldırıldı.
|
||||||
|
|
||||||
|
Bunun yerine `a2wsgi` paketini kullanmanız önerilir. Kullanım aynıdır.
|
||||||
|
|
||||||
|
Sadece `a2wsgi` paketinin kurulu olduğundan emin olun ve `WSGIMiddleware`'ı `a2wsgi` içinden doğru şekilde import edin.
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
## Kontrol Edelim { #check-it }
|
## Kontrol Edelim { #check-it }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,6 @@ $ pip install "fastapi[standard]"
|
||||||
Şu içerikle `main.py` adında bir dosya oluşturalım:
|
Şu içerikle `main.py` adında bir dosya oluşturalım:
|
||||||
|
|
||||||
```Python
|
```Python
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
@ -174,7 +172,7 @@ def read_root():
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/{item_id}")
|
@app.get("/items/{item_id}")
|
||||||
def read_item(item_id: int, q: Union[str, None] = None):
|
def read_item(item_id: int, q: str | None = None):
|
||||||
return {"item_id": item_id, "q": q}
|
return {"item_id": item_id, "q": q}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -183,9 +181,7 @@ def read_item(item_id: int, q: Union[str, None] = None):
|
||||||
|
|
||||||
Eğer kodunuz `async` / `await` kullanıyorsa, `async def` kullanın:
|
Eğer kodunuz `async` / `await` kullanıyorsa, `async def` kullanın:
|
||||||
|
|
||||||
```Python hl_lines="9 14"
|
```Python hl_lines="7 12"
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
@ -197,7 +193,7 @@ async def read_root():
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/{item_id}")
|
@app.get("/items/{item_id}")
|
||||||
async def read_item(item_id: int, q: Union[str, None] = None):
|
async def read_item(item_id: int, q: str | None = None):
|
||||||
return {"item_id": item_id, "q": q}
|
return {"item_id": item_id, "q": q}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -288,9 +284,7 @@ Alternatif otomatik dokümantasyonu göreceksiniz (<a href="https://github.com/R
|
||||||
|
|
||||||
Body'yi Pydantic sayesinde standart Python tiplerini kullanarak tanımlayalım.
|
Body'yi Pydantic sayesinde standart Python tiplerini kullanarak tanımlayalım.
|
||||||
|
|
||||||
```Python hl_lines="4 9-12 25-27"
|
```Python hl_lines="2 7-10 23-25"
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
@ -300,7 +294,7 @@ app = FastAPI()
|
||||||
class Item(BaseModel):
|
class Item(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
price: float
|
price: float
|
||||||
is_offer: Union[bool, None] = None
|
is_offer: bool | None = None
|
||||||
|
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
|
|
@ -309,7 +303,7 @@ def read_root():
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/{item_id}")
|
@app.get("/items/{item_id}")
|
||||||
def read_item(item_id: int, q: Union[str, None] = None):
|
def read_item(item_id: int, q: str | None = None):
|
||||||
return {"item_id": item_id, "q": q}
|
return {"item_id": item_id, "q": q}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue