Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 39 for include_router (0.39 sec)

  1. tests/test_ws_router.py

    async def router_ws_custom_error(websocket: WebSocket):
        raise CustomError()
    
    
    def make_app(app=None, **kwargs):
        app = app or FastAPI(**kwargs)
        app.include_router(router)
        app.include_router(prefix_router, prefix="/prefix")
        app.include_router(native_prefix_route)
        return app
    
    
    app = make_app(app)
    
    
    def test_app():
        client = TestClient(app)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  2. docs_src/bigger_applications/app_an/main.py

    from .dependencies import get_query_token, get_token_header
    from .internal import admin
    from .routers import items, users
    
    app = FastAPI(dependencies=[Depends(get_query_token)])
    
    
    app.include_router(users.router)
    app.include_router(items.router)
    app.include_router(
        admin.router,
        prefix="/admin",
        tags=["admin"],
        dependencies=[Depends(get_token_header)],
        responses={418: {"description": "I'm a teapot"}},
    )
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 552 bytes
    - Viewed (0)
  3. 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)
  4. docs_src/bigger_applications/app_an_py39/main.py

    from .dependencies import get_query_token, get_token_header
    from .internal import admin
    from .routers import items, users
    
    app = FastAPI(dependencies=[Depends(get_query_token)])
    
    
    app.include_router(users.router)
    app.include_router(items.router)
    app.include_router(
        admin.router,
        prefix="/admin",
        tags=["admin"],
        dependencies=[Depends(get_token_header)],
        responses={418: {"description": "I'm a teapot"}},
    )
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 552 bytes
    - Viewed (0)
  5. tests/test_modules_same_name_body/app/main.py

    from fastapi import FastAPI
    
    from . import a, b
    
    app = FastAPI()
    
    app.include_router(a.router, prefix="/a")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jun 28 17:35:16 GMT 2019
    - 150 bytes
    - Viewed (0)
  6. tests/test_default_response_class.py

        return {"msg": "Hello B A C"}
    
    
    router_b_a.include_router(
        router_b_a_c_override, prefix="/c", default_response_class=HTMLResponse
    )
    router_b_override.include_router(router_b_a, prefix="/a")
    router_a.include_router(router_a_a, prefix="/a")
    router_a.include_router(
        router_a_b_override, prefix="/b", default_response_class=PlainTextResponse
    )
    app.include_router(router_a, prefix="/a")
    app.include_router(
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Mar 01 20:49:20 GMT 2020
    - 5.2K bytes
    - Viewed (0)
  7. 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)
  8. docs/zh/docs/advanced/testing-dependencies.md

    ```Python hl_lines="26-27  30"
    {!../../../docs_src/dependency_testing/tutorial001.py!}
    ```
    
    !!! tip "提示"
    
        **FastAPI** 应用中的任何位置都可以实现覆盖依赖项。
    
        原依赖项可用于*路径操作函数*、*路径操作装饰器*(不需要返回值时)、`.include_router()` 调用等。
    
        FastAPI 可以覆盖这些位置的依赖项。
    
    然后,使用 `app.dependency_overrides` 把覆盖依赖项重置为空**字典**:
    
    ```Python
    app.dependency_overrides = {}
    ```
    
    !!! tip "提示"
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 22:45:53 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  9. docs/de/docs/reference/apirouter.md

    Sie können die `APIRouter`-Klasse direkt von `fastapi` importieren:
    
    ```python
    from fastapi import APIRouter
    ```
    
    ::: fastapi.APIRouter
        options:
            members:
                - websocket
                - include_router
                - get
                - put
                - post
                - delete
                - options
                - head
                - patch
                - trace
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 18:16:35 GMT 2024
    - 538 bytes
    - Viewed (0)
  10. docs/en/docs/reference/apirouter.md

    You can import the `APIRouter` class directly from `fastapi`:
    
    ```python
    from fastapi import APIRouter
    ```
    
    ::: fastapi.APIRouter
        options:
            members:
                - websocket
                - include_router
                - get
                - put
                - post
                - delete
                - options
                - head
                - patch
                - trace
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 524 bytes
    - Viewed (0)
Back to top