Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 101 - 110 of 207 for outer (0.02 seconds)

  1. docs/zh-hant/docs/tutorial/bigger-applications.md

    ///
    
    ### 避免名稱衝突 { #avoid-name-collisions }
    
    我們直接匯入子模組 `items`,而不是只匯入它的變數 `router`。
    
    這是因為在子模組 `users` 中也有另一個名為 `router` 的變數。
    
    如果我們像下面這樣一個接一個匯入:
    
    ```Python
    from .routers.items import router
    from .routers.users import router
    ```
    
    來自 `users` 的 `router` 會覆蓋掉 `items` 的 `router`,我們就無法同時使用兩者。
    
    因此,為了能在同一個檔案中同時使用它們,我們直接匯入子模組:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 18.7K bytes
    - Click Count (0)
  2. tests/test_additional_response_extra.py

    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    
    router = APIRouter()
    
    sub_router = APIRouter()
    
    app = FastAPI()
    
    
    @sub_router.get("/")
    def read_item():
        return {"id": "foo"}
    
    
    router.include_router(sub_router, prefix="/items")
    
    app.include_router(router)
    
    client = TestClient(app)
    
    
    def test_path_operation():
        response = client.get("/items/")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 1.3K bytes
    - Click Count (0)
  3. docs/ru/docs/tutorial/bigger-applications.md

    Это потому, что у нас также есть другая переменная с именем `router` в подмодуле `users`.
    
    Если бы мы импортировали их одну за другой, как здесь:
    
    ```Python
    from .routers.items import router
    from .routers.users import router
    ```
    
    то `router` из `users` перезаписал бы `router` из `items`, и мы не смогли бы использовать их одновременно.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:56:20 GMT 2026
    - 29.7K bytes
    - Click Count (0)
  4. tests/test_router_prefix_with_template.py

    from fastapi import APIRouter, FastAPI
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    router = APIRouter()
    
    
    @router.get("/users/{id}")
    def read_user(segment: str, id: str):
        return {"segment": segment, "id": id}
    
    
    app.include_router(router, prefix="/{segment}")
    
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.get("/seg/users/foo")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Apr 08 04:37:38 GMT 2020
    - 484 bytes
    - Click Count (0)
  5. tests/test_modules_same_name_body/app/b.py

    from fastapi import APIRouter, Body
    
    router = APIRouter()
    
    
    @router.post("/compute/")
    def compute(a: int = Body(), b: str = Body()):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 161 bytes
    - Click Count (0)
  6. docs/uk/docs/tutorial/bigger-applications.md

    Ми імпортуємо підмодуль `items` напряму, замість імпорту лише його змінної `router`.
    
    Це тому, що в підмодулі `users` також є змінна з назвою `router`.
    
    Якби ми імпортували один за одним, як:
    
    ```Python
    from .routers.items import router
    from .routers.users import router
    ```
    
    `router` з `users` перезаписав би той, що з `items`, і ми не змогли б використовувати їх одночасно.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:27:41 GMT 2026
    - 27.4K bytes
    - Click Count (0)
  7. tests/test_custom_route_class.py

    
    @router_b.get("/")
    def get_b():
        return {"msg": "B"}
    
    
    @router_c.get("/")
    def get_c():
        return {"msg": "C"}
    
    
    router_b.include_router(router=router_c, prefix="/c")
    router_a.include_router(router=router_b, prefix="/b")
    app.include_router(router=router_a, prefix="/a")
    
    
    client = TestClient(app)
    
    
    @pytest.mark.parametrize(
        "path,expected_status,expected_response",
        [
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 3.3K bytes
    - Click Count (0)
  8. docs/ko/docs/tutorial/bigger-applications.md

    ///
    
    ### 이름 충돌 피하기 { #avoid-name-collisions }
    
    submodule `items`를 직접 import하고, 그 안의 `router` 변수만 import하지는 않습니다.
    
    이는 submodule `users`에도 `router`라는 이름의 변수가 있기 때문입니다.
    
    만약 다음처럼 순서대로 import했다면:
    
    ```Python
    from .routers.items import router
    from .routers.users import router
    ```
    
    `users`의 `router`가 `items`의 `router`를 덮어써서 동시에 사용할 수 없게 됩니다.
    
    따라서 같은 파일에서 둘 다 사용할 수 있도록 submodule들을 직접 import합니다:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:06:26 GMT 2026
    - 21.5K bytes
    - Click Count (0)
  9. tests/test_custom_middleware_exception.py

                return
    
            wrapper = self.receive_wrapper(receive)
            await self.app(scope, wrapper, send)
    
    
    @router.post("/middleware")
    def run_middleware(file: UploadFile = File(..., description="Big File")):
        return {"message": "OK"}
    
    
    app.include_router(router)
    app.add_middleware(ContentSizeLimitMiddleware, max_content_size=2**8)
    
    
    client = TestClient(app)
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 2.8K bytes
    - Click Count (0)
  10. tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py

    )
    async def read_with_get_token():
        return {"message": "Admin Access"}
    
    
    router = APIRouter(dependencies=[Security(oauth2_scheme, scopes=["read"])])
    
    
    @router.get("/items/")
    async def read_items(token: str | None = Depends(oauth2_scheme)):
        return {"token": token}
    
    
    @router.post("/items/")
    async def create_item(
        token: str | None = Security(oauth2_scheme, scopes=["read", "write"]),
    ):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 6.6K bytes
    - Click Count (0)
Back to Top