Search Options

Results per page
Sort
Preferred Languages
Advance

Results 81 - 90 of 410 for depende (0.08 sec)

  1. docs_src/dependencies/tutorial008_an.py

    from fastapi import Depends
    from typing_extensions import Annotated
    
    
    async def dependency_a():
        dep_a = generate_dep_a()
        try:
            yield dep_a
        finally:
            dep_a.close()
    
    
    async def dependency_b(dep_a: Annotated[DepA, Depends(dependency_a)]):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 531 bytes
    - Viewed (0)
  2. docs_src/bigger_applications/app/main.py

    from fastapi import Depends, FastAPI
    
    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)],
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sun Nov 29 17:32:18 UTC 2020
    - 552 bytes
    - Viewed (0)
  3. docs_src/dependencies/tutorial001.py

    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    async def common_parameters(
        q: Union[str, None] = None, skip: int = 0, limit: int = 100
    ):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/items/")
    async def read_items(commons: dict = Depends(common_parameters)):
        return commons
    
    
    @app.get("/users/")
    async def read_users(commons: dict = Depends(common_parameters)):
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 442 bytes
    - Viewed (0)
  4. docs_src/dependencies/tutorial001_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    async def common_parameters(
        q: Union[str, None] = None, skip: int = 0, limit: int = 100
    ):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/items/")
    async def read_items(commons: Annotated[dict, Depends(common_parameters)]):
        return commons
    
    
    @app.get("/users/")
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 473 bytes
    - Viewed (0)
  5. docs_src/dependencies/tutorial008d_an_py39.py

    from fastapi import Depends, FastAPI, HTTPException
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("We don't swallow the internal error here, we raise again 😎")
            raise
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Feb 24 23:06:37 UTC 2024
    - 734 bytes
    - Viewed (0)
  6. docs_src/dependencies/tutorial006.py

    @app.get("/items/", dependencies=[Depends(verify_token), Depends(verify_key)])
    async def read_items():
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 583 bytes
    - Viewed (0)
  7. docs_src/dependencies/tutorial005_py310.py

    from fastapi import Cookie, Depends, FastAPI
    
    app = FastAPI()
    
    
    def query_extractor(q: str | None = None):
        return q
    
    
    def query_or_cookie_extractor(
        q: str = Depends(query_extractor), last_query: str | None = Cookie(default=None)
    ):
        if not q:
            return last_query
        return q
    
    
    @app.get("/items/")
    async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 443 bytes
    - Viewed (0)
  8. docs/ko/docs/tutorial/dependencies/index.md

    {!> ../../docs_src/dependencies/tutorial001.py!}
    ```
    
    ////
    
    비둝 `Body`, `Query` 등을 μ‚¬μš©ν•˜λŠ” 것과 같은 λ°©μ‹μœΌλ‘œ μ—¬λŸ¬λΆ„μ˜ ν•¨μˆ˜μ˜ λ§€κ°œλ³€μˆ˜μ— μžˆλŠ” `Depends`λ₯Ό μ‚¬μš©ν•˜μ§€λ§Œ, `Depends`λŠ” μ•½κ°„ λ‹€λ₯΄κ²Œ μž‘λ™ν•©λ‹ˆλ‹€.
    
    `Depends`에 단일 λ§€κ°œλ³€μˆ˜λ§Œ μ „λ‹¬ν–ˆμŠ΅λ‹ˆλ‹€.
    
    이 λ§€κ°œλ³€μˆ˜λŠ” ν•¨μˆ˜κ°™μ€ 것이어야 ν•©λ‹ˆλ‹€.
    
    μ—¬λŸ¬λΆ„μ€ 직접 **ν˜ΈμΆœν•˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€** (끝에 κ΄„ν˜Έλ₯Ό μΉ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€), 단지 `Depends()`에 λ§€κ°œλ³€μˆ˜λ‘œ λ„˜κ²¨ 쀬을 λΏμž…λ‹ˆλ‹€.
    
    그리고 κ·Έ ν•¨μˆ˜λŠ” *경둜 μž‘λ™ ν•¨μˆ˜*κ°€ μž‘λ™ν•˜λŠ” 것과 같은 λ°©μ‹μœΌλ‘œ λ§€κ°œλ³€μˆ˜λ₯Ό λ°›μŠ΅λ‹ˆλ‹€.
    
    /// tip | "팁"
    
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 13.5K bytes
    - Viewed (0)
  9. docs_src/dependencies/tutorial005.py

    from fastapi import Cookie, Depends, FastAPI
    
    app = FastAPI()
    
    
    def query_extractor(q: Union[str, None] = None):
        return q
    
    
    def query_or_cookie_extractor(
        q: str = Depends(query_extractor),
        last_query: Union[str, None] = Cookie(default=None),
    ):
        if not q:
            return last_query
        return q
    
    
    @app.get("/items/")
    async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 486 bytes
    - Viewed (0)
  10. docs_src/dependencies/tutorial005_an_py310.py

    from typing import Annotated
    
    from fastapi import Cookie, Depends, FastAPI
    
    app = FastAPI()
    
    
    def query_extractor(q: str | None = None):
        return q
    
    
    def query_or_cookie_extractor(
        q: Annotated[str, Depends(query_extractor)],
        last_query: Annotated[str | None, Cookie()] = None,
    ):
        if not q:
            return last_query
        return q
    
    
    @app.get("/items/")
    async def read_query(
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Tue Mar 26 16:56:53 UTC 2024
    - 510 bytes
    - Viewed (0)
Back to top