Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 421 for depende (0.06 sec)

  1. docs_src/security/tutorial004_an_py310.py

    
    async def get_current_active_user(
        current_user: Annotated[User, Depends(get_current_user)],
    ):
        if current_user.disabled:
            raise HTTPException(status_code=400, detail="Inactive user")
        return current_user
    
    
    @app.post("/token")
    async def login_for_access_token(
        form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
    ) -> Token:
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4.1K bytes
    - Viewed (0)
  2. docs/en/docs/virtual-environments.md

    At some point, you will probably end up writing many different programs that depend on **different packages**. And some of these projects you work on will depend on **different versions** of the same package. 😱
    
    For example, you could create a project called `philosophers-stone`, this program depends on another package called **`harry`, using the version `1`**. So, you need to install `harry`.
    
    ```mermaid
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Aug 24 03:16:23 UTC 2024
    - 21.7K bytes
    - Viewed (0)
  3. tests/test_repeated_dependency_schema.py

    from fastapi import Depends, FastAPI, Header, status
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    def get_header(*, someheader: str = Header()):
        return someheader
    
    
    def get_something_else(*, someheader: str = Depends(get_header)):
        return f"{someheader}123"
    
    
    @app.get("/")
    def get_deps(dep1: str = Depends(get_header), dep2: str = Depends(get_something_else)):
        return {"dep1": dep1, "dep2": dep2}
    
    
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 3.2K bytes
    - Viewed (0)
  4. docs_src/dependencies/tutorial008_an_py39.py

    from fastapi import Depends
    
    
    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)
    
    
    async def dependency_c(dep_b: Annotated[DepB, Depends(dependency_b)]):
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 521 bytes
    - Viewed (0)
  5. docs_src/bigger_applications/app_an_py39/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: Sat Mar 18 12:29:59 UTC 2023
    - 552 bytes
    - Viewed (0)
  6. docs_src/dependencies/tutorial005_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Cookie, Depends, FastAPI
    
    app = FastAPI()
    
    
    def query_extractor(q: Union[str, None] = None):
        return q
    
    
    def query_or_cookie_extractor(
        q: Annotated[str, Depends(query_extractor)],
        last_query: Annotated[Union[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
    - 529 bytes
    - Viewed (0)
  7. docs_src/bigger_applications/app_an/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: Sat Mar 18 12:29:59 UTC 2023
    - 552 bytes
    - Viewed (0)
  8. docs/en/docs/reference/dependencies.md

    # Dependencies - `Depends()` and `Security()`
    
    ## `Depends()`
    
    Dependencies are handled mainly with the special function `Depends()` that takes a callable.
    
    Here is the reference for it and its parameters.
    
    You can import it directly from `fastapi`:
    
    ```python
    from fastapi import Depends
    ```
    
    ::: fastapi.Depends
    
    ## `Security()`
    
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:53:19 UTC 2024
    - 671 bytes
    - Viewed (0)
  9. docs/ko/docs/tutorial/dependencies/classes-as-dependencies.md

    **FastAPI**λŠ” `CommonQueryParams` 클래슀λ₯Ό ν˜ΈμΆœν•©λ‹ˆλ‹€. 이것은 ν•΄λ‹Ή 클래슀의 "μΈμŠ€ν„΄μŠ€"λ₯Ό μƒμ„±ν•˜κ³  κ·Έ μΈμŠ€ν„΄μŠ€λŠ” ν•¨μˆ˜μ˜ λ§€κ°œλ³€μˆ˜ `commons`둜 μ „λ‹¬λ©λ‹ˆλ‹€.
    
    ## νƒ€μž… νžŒνŒ… vs `Depends`
    
    μœ„ μ½”λ“œμ—μ„œ `CommonQueryParams`λ₯Ό 두 번 μž‘μ„±ν•œ 방식에 μ£Όλͺ©ν•˜μ‹­μ‹œμ˜€:
    
    ```Python
    commons: CommonQueryParams = Depends(CommonQueryParams)
    ```
    
    λ§ˆμ§€λ§‰ `CommonQueryParams` λ³€μˆ˜λ₯Ό 보면:
    
    ```Python
    ... = Depends(CommonQueryParams)
    ```
    
    ... **FastAPI**κ°€ μ‹€μ œλ‘œ μ–΄λ–€ 것이 μ˜μ‘΄μ„±μΈμ§€ μ•ŒκΈ° μœ„ν•΄μ„œ μ‚¬μš©ν•˜λŠ” λ°©λ²•μž…λ‹ˆλ‹€.
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 7.9K bytes
    - Viewed (0)
  10. docs_src/security/tutorial002_py310.py

        )
    
    
    async def get_current_user(token: str = Depends(oauth2_scheme)):
        user = fake_decode_token(token)
        return user
    
    
    @app.get("/users/me")
    async def read_users_me(current_user: User = Depends(get_current_user)):
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 711 bytes
    - Viewed (0)
Back to top