Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 309 for Depends (0.08 sec)

  1. docs_src/sql_databases_peewee/sql_app/main.py

    
    def get_db(db_state=Depends(reset_db_state)):
        try:
            database.db.connect()
            yield
        finally:
            if not database.db.is_closed():
                database.db.close()
    
    
    @app.post("/users/", response_model=schemas.User, dependencies=[Depends(get_db)])
    def create_user(user: schemas.UserCreate):
        db_user = crud.get_user_by_email(email=user.email)
        if db_user:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 2.2K bytes
    - Viewed (0)
  2. docs/em/docs/tutorial/dependencies/classes-as-dependencies.md

    ////
    
    **FastAPI** ๐Ÿค™ `CommonQueryParams` ๐ŸŽ“. ๐Ÿ‘‰ โœ "๐Ÿ‘" ๐Ÿ‘ˆ ๐ŸŽ“ & ๐Ÿ‘ ๐Ÿ”œ ๐Ÿšถโ€โ™€๏ธ ๐Ÿ”ข `commons` ๐Ÿ‘† ๐Ÿ”ข.
    
    ## ๐Ÿ†Ž โœ ๐Ÿ†š `Depends`
    
    ๐Ÿ‘€ โ” ๐Ÿ‘ฅ โœ `CommonQueryParams` ๐Ÿ• ๐Ÿ”› ๐Ÿ“Ÿ:
    
    ```Python
    commons: CommonQueryParams = Depends(CommonQueryParams)
    ```
    
    ๐Ÿ `CommonQueryParams`,:
    
    ```Python
    ... = Depends(CommonQueryParams)
    ```
    
    ...โšซ๏ธโ” **FastAPI** ๐Ÿ”œ ๐Ÿค™ โš™๏ธ ๐Ÿ’ญ โšซ๏ธโ” ๐Ÿ”—.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 5.9K bytes
    - Viewed (0)
  3. docs_src/sql_databases/tutorial002.py

    @app.post("/heroes/", response_model=HeroPublic)
    def create_hero(hero: HeroCreate, session: Session = Depends(get_session)):
        db_hero = Hero.model_validate(hero)
        session.add(db_hero)
        session.commit()
        session.refresh(db_hero)
        return db_hero
    
    
    @app.get("/heroes/", response_model=List[HeroPublic])
    def read_heroes(
        session: Session = Depends(get_session),
        offset: int = 0,
        limit: int = Query(default=100, le=100),
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  4. docs_src/security/tutorial003_an_py310.py

        return user
    
    
    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(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):
        user_dict = fake_users_db.get(form_data.username)
        if not user_dict:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Mar 26 16:56:53 UTC 2024
    - 2.5K bytes
    - Viewed (0)
  5. docs_src/sql_databases/tutorial002_py39.py

    @app.post("/heroes/", response_model=HeroPublic)
    def create_hero(hero: HeroCreate, session: Session = Depends(get_session)):
        db_hero = Hero.model_validate(hero)
        session.add(db_hero)
        session.commit()
        session.refresh(db_hero)
        return db_hero
    
    
    @app.get("/heroes/", response_model=list[HeroPublic])
    def read_heroes(
        session: Session = Depends(get_session),
        offset: int = 0,
        limit: int = Query(default=100, le=100),
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  6. docs_src/security/tutorial004_an.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 Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4.2K bytes
    - Viewed (0)
  7. docs_src/sql_databases/tutorial001_py39.py

    def on_startup():
        create_db_and_tables()
    
    
    @app.post("/heroes/")
    def create_hero(hero: Hero, session: Session = Depends(get_session)) -> Hero:
        session.add(hero)
        session.commit()
        session.refresh(hero)
        return hero
    
    
    @app.get("/heroes/")
    def read_heroes(
        session: Session = Depends(get_session),
        offset: int = 0,
        limit: int = Query(default=100, le=100),
    ) -> list[Hero]:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.8K bytes
    - Viewed (0)
  8. docs/zh/docs/tutorial/dependencies/classes-as-dependencies.md

    ```
    
    ////
    
    **FastAPI** ่ฐƒ็”จ `CommonQueryParams` ็ฑปใ€‚่ฟ™ๅฐ†ๅˆ›ๅปบ่ฏฅ็ฑป็š„ไธ€ไธช "ๅฎžไพ‹"๏ผŒ่ฏฅๅฎžไพ‹ๅฐ†ไฝœไธบๅ‚ๆ•ฐ `commons` ่ขซไผ ้€’็ป™ไฝ ็š„ๅ‡ฝๆ•ฐใ€‚
    
    ## ็ฑปๅž‹ๆณจ่งฃ vs `Depends`
    
    ๆณจๆ„๏ผŒๆˆ‘ไปฌๅœจไธŠ้ข็š„ไปฃ็ ไธญ็ผ–ๅ†™ไบ†ไธคๆฌก`CommonQueryParams`๏ผš
    
    ```Python
    commons: CommonQueryParams = Depends(CommonQueryParams)
    ```
    
    ๆœ€ๅŽ็š„ `CommonQueryParams`:
    
    ```Python
    ... = Depends(CommonQueryParams)
    ```
    
    ...ๅฎž้™…ไธŠๆ˜ฏ **Fastapi** ็”จๆฅ็Ÿฅ้“ไพ่ต–้กนๆ˜ฏไป€ไนˆ็š„ใ€‚
    
    FastAPI ๅฐ†ไปŽไพ่ต–้กนไธญๆๅ–ๅฃฐๆ˜Ž็š„ๅ‚ๆ•ฐ๏ผŒ่ฟ™ๆ‰ๆ˜ฏ FastAPI ๅฎž้™…่ฐƒ็”จ็š„ใ€‚
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.4K bytes
    - Viewed (0)
  9. docs_src/security/tutorial004.py

        return user
    
    
    async def get_current_active_user(current_user: 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: OAuth2PasswordRequestForm = Depends(),
    ) -> Token:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4.1K bytes
    - Viewed (0)
  10. 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 Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4.1K bytes
    - Viewed (0)
Back to top