Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 21 - 30 of 57 for include_router (0.08 seconds)

  1. tests/test_router_redirect_slashes.py

    
    def test_redirect_slashes_enabled():
        app = FastAPI()
        router = APIRouter()
    
        @router.get("/hello/")
        def hello_page() -> str:
            return "Hello, World!"
    
        app.include_router(router)
    
        client = TestClient(app)
    
        response = client.get("/hello/", follow_redirects=False)
        assert response.status_code == 200
    
        response = client.get("/hello", follow_redirects=False)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Jun 22 10:37:50 GMT 2023
    - 974 bytes
    - Click Count (0)
  2. tests/test_include_route.py

    from fastapi.testclient import TestClient
    
    app = FastAPI()
    router = APIRouter()
    
    
    @router.route("/items/")
    def read_items(request: Request):
        return JSONResponse({"hello": "world"})
    
    
    app.include_router(router)
    
    client = TestClient(app)
    
    
    def test_sub_router():
        response = client.get("/items/")
        assert response.status_code == 200, response.text
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Apr 08 04:37:38 GMT 2020
    - 496 bytes
    - Click Count (0)
  3. fastapi/routing.py

            users_router = APIRouter()
    
            @users_router.get("/users/")
            def read_users():
                return [{"name": "Rick"}, {"name": "Morty"}]
    
            internal_router.include_router(users_router)
            app.include_router(internal_router)
            ```
            """
            assert self is not router, (
                "Cannot include the same APIRouter instance into itself. "
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 193K bytes
    - Click Count (0)
  4. tests/test_router_circular_import.py

        router = APIRouter()
    
        with pytest.raises(
            AssertionError,
            match="Cannot include the same APIRouter instance into itself. Did you mean to include a different router?",
        ):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 10 10:58:40 GMT 2026
    - 317 bytes
    - Click Count (0)
  5. docs_src/custom_request_and_route/tutorial003_py310.py

    
    @app.get("/")
    async def not_timed():
        return {"message": "Not timed"}
    
    
    @router.get("/timed")
    async def timed():
        return {"message": "It's the time of my life"}
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 10 08:55:32 GMT 2025
    - 1K bytes
    - Click Count (0)
  6. tests/test_dependency_yield_scope.py

            )
    
        return StreamingResponse(iter_data())
    
    
    app.include_router(
        prefix="/router-scope-function",
        router=router,
        dependencies=[Depends(raise_after_yield, scope="function")],
    )
    
    app.include_router(
        prefix="/router-scope-request",
        router=router,
        dependencies=[Depends(raise_after_yield, scope="request")],
    )
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 6.7K bytes
    - Click Count (0)
  7. docs/tr/docs/tutorial/bigger-applications.md

    /// info | Bilgi
    
    `users.router`, `app/routers/users.py` dosyasının içindeki `APIRouter`’ı içerir.
    
    `items.router` ise `app/routers/items.py` dosyasının içindeki `APIRouter`’ı içerir.
    
    ///
    
    `app.include_router()` ile her bir `APIRouter`’ı ana `FastAPI` uygulamasına ekleyebiliriz.
    
    Böylece o router içindeki tüm route’lar uygulamanın bir parçası olarak dahil edilir.
    
    /// note | Teknik Detaylar
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 07:53:17 GMT 2026
    - 20.3K bytes
    - Click Count (0)
  8. docs/ru/docs/tutorial/bigger-applications.md

    /// info | Примечание
    
    `users.router` содержит `APIRouter` из файла `app/routers/users.py`.
    
    А `items.router` содержит `APIRouter` из файла `app/routers/items.py`.
    
    ///
    
    С помощью `app.include_router()` мы можем добавить каждый `APIRouter` в основное приложение `FastAPI`.
    
    Он включит все маршруты этого маршрутизатора как часть приложения.
    
    /// note | Технические детали
    
    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)
  9. docs/de/docs/tutorial/bigger-applications.md

    /// info | 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
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:58:09 GMT 2026
    - 21.9K bytes
    - Click Count (0)
  10. docs/zh-hant/docs/tutorial/bigger-applications.md

    你也可以用不同的前綴,對同一個 router 多次呼叫 `.include_router()`。
    
    例如,這對於在不同前綴下提供相同的 API 很有用,如 `/api/v1` 與 `/api/latest`。
    
    這是進階用法,你可能不會需要,但若有需要它就在那裡。
    
    ## 在另一個 `APIRouter` 中納入一個 `APIRouter` { #include-an-apirouter-in-another }
    
    就像你可以在 `FastAPI` 應用中納入一個 `APIRouter` 一樣,你也可以在另一個 `APIRouter` 中納入一個 `APIRouter`,用法如下:
    
    ```Python
    router.include_router(other_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)
Back to Top