Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 8 of 8 for include_router (0.39 sec)

  1. docs/en/docs/tutorial/bigger-applications.md

    ```
    
    !!! info
        `users.router` contains the `APIRouter` inside of the file `app/routers/users.py`.
    
        And `items.router` contains the `APIRouter` inside of the file `app/routers/items.py`.
    
    With `app.include_router()` we can add each `APIRouter` to the main `FastAPI` application.
    
    It will include all the routes from that router as part of it.
    
    !!! note "Technical Details"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 18.6K bytes
    - Viewed (0)
  2. docs/zh/docs/tutorial/bigger-applications.md

    ## 多次使用不同的 `prefix` 包含同一个路由器
    
    你也可以在*同一*路由器上使用不同的前缀来多次使用 `.include_router()`。
    
    在有些场景这可能有用,例如以不同的前缀公开同一个的 API,比方说 `/api/v1` 和 `/api/latest`。
    
    这是一个你可能并不真正需要的高级用法,但万一你有需要了就能够用上。
    
    ## 在另一个 `APIRouter` 中包含一个 `APIRouter`
    
    与在 `FastAPI` 应用程序中包含 `APIRouter` 的方式相同,你也可以在另一个 `APIRouter` 中包含 `APIRouter`,通过:
    
    ```Python
    router.include_router(other_router)
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 18.5K bytes
    - Viewed (0)
  3. tests/test_infer_param_optionality.py

        if user_id is None:
            return {"item_id": item_id}
        else:
            return {"item_id": item_id, "user_id": user_id}
    
    
    app.include_router(user_router, prefix="/users")
    app.include_router(item_router, prefix="/items")
    
    app.include_router(item_router, prefix="/users/{user_id}/items")
    
    
    client = TestClient(app)
    
    
    def test_get_users():
        """Check that /users returns expected data"""
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.3K bytes
    - Viewed (0)
  4. docs/de/docs/tutorial/bigger-applications.md

    ```
    
    !!! info
        `users.router` enthält den `APIRouter` in der Datei `app/routers/users.py`.
    
        Und `items.router` enthält den `APIRouter` in der Datei `app/routers/items.py`.
    
    Mit `app.include_router()` können wir jeden `APIRouter` zur Hauptanwendung `FastAPI` hinzufügen.
    
    Es wird alle Routen von diesem Router als Teil von dieser inkludieren.
    
    !!! note "Technische Details"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:27:59 GMT 2024
    - 21.1K bytes
    - Viewed (0)
  5. docs/em/docs/tutorial/bigger-applications.md

    ## 🔌 🎏 📻 💗 🕰 ⏮️ 🎏 `prefix`
    
    👆 💪 ⚙️ `.include_router()` 💗 🕰 ⏮️ *🎏* 📻 ⚙️ 🎏 🔡.
    
    👉 💪 ⚠, 🖼, 🎦 🎏 🛠️ 🔽 🎏 🔡, ✅ `/api/v1` & `/api/latest`.
    
    👉 🏧 ⚙️ 👈 👆 5️⃣📆 🚫 🤙 💪, ✋️ ⚫️ 📤 💼 👆.
    
    ## 🔌 `APIRouter` ➕1️⃣
    
    🎏 🌌 👆 💪 🔌 `APIRouter` `FastAPI` 🈸, 👆 💪 🔌 `APIRouter` ➕1️⃣ `APIRouter` ⚙️:
    
    ```Python
    router.include_router(other_router)
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 15.6K bytes
    - Viewed (0)
  6. tests/test_dependency_overrides.py

    
    @router.get("/router-decorator-depends/", dependencies=[Depends(common_parameters)])
    async def router_decorator_depends():
        return {"in": "router-decorator-depends"}
    
    
    app.include_router(router)
    
    client = TestClient(app)
    
    
    async def overrider_dependency_simple(q: Optional[str] = None):
        return {"q": q, "skip": 5, "limit": 10}
    
    
    async def overrider_sub_dependency(k: str):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 15.4K bytes
    - Viewed (0)
  7. tests/test_sub_callbacks.py

                (e.g. "payment successful").
        """
        # Send the invoice, collect the money, send the notification (the callback)
        return {"msg": "Invoice received"}
    
    
    app.include_router(subrouter, callbacks=events_callback_router.routes)
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.post(
            "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.8K bytes
    - Viewed (0)
  8. tests/test_annotated.py

        app = FastAPI()
    
        router = APIRouter(prefix="/nested")
    
        @router.get("/test")
        async def test(var: Annotated[str, Query()] = "bar"):
            return {"foo": var}
    
        app.include_router(router)
    
        client = TestClient(app)
    
        response = client.get("/nested/test")
        assert response.status_code == 200
        assert response.json() == {"foo": "bar"}
    
    
    def test_openapi_schema():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 10.2K bytes
    - Viewed (0)
Back to top