Search Options

Results per page
Sort
Preferred Languages
Advance

Results 111 - 120 of 585 for Depends (0.12 sec)

  1. docs_src/dependency_testing/tutorial001_an.py

    from typing import Union
    
    from fastapi import Depends, FastAPI
    from fastapi.testclient import TestClient
    from typing_extensions import Annotated
    
    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)]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 1.5K bytes
    - Viewed (0)
  2. docs_src/security/tutorial001.py

    from fastapi import Depends, FastAPI
    from fastapi.security import OAuth2PasswordBearer
    
    app = FastAPI()
    
    oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
    
    
    @app.get("/items/")
    async def read_items(token: str = Depends(oauth2_scheme)):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 10 17:28:18 UTC 2020
    - 269 bytes
    - Viewed (0)
  3. tests/test_dependency_security_overrides.py

    from typing import List, Tuple
    
    from fastapi import Depends, FastAPI, Security
    from fastapi.security import SecurityScopes
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    def get_user(required_scopes: SecurityScopes):
        return "john", required_scopes.scopes
    
    
    def get_user_override(required_scopes: SecurityScopes):
        return "alice", required_scopes.scopes
    
    
    def get_data():
        return [1, 2, 3]
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Jun 14 15:54:46 UTC 2020
    - 1.4K bytes
    - Viewed (0)
  4. docs/em/docs/advanced/security/oauth2-scopes.md

    ๐Ÿ‘‰, ๐Ÿ‘ฅ ๐Ÿ—„ & โš™๏ธ `Security` โšช๏ธโžก๏ธ `fastapi`.
    
    ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ `Security` ๐Ÿ“ฃ ๐Ÿ”— (๐Ÿ’– `Depends`), โœ‹๏ธ `Security` ๐Ÿ“จ ๐Ÿ”ข `scopes` โฎ๏ธ ๐Ÿ“‡ โ†” (๐ŸŽป).
    
    ๐Ÿ‘‰ ๐Ÿ’ผ, ๐Ÿ‘ฅ ๐Ÿšถโ€โ™€๏ธ ๐Ÿ”— ๐Ÿ”ข `get_current_active_user` `Security` (๐ŸŽ ๐ŸŒŒ ๐Ÿ‘ฅ ๐Ÿ”œ โฎ๏ธ `Depends`).
    
    โœ‹๏ธ ๐Ÿ‘ฅ ๐Ÿšถโ€โ™€๏ธ `list` โ†”, ๐Ÿ‘‰ ๐Ÿ’ผ โฎ๏ธ 1๏ธโƒฃ โ†”: `items` (โšซ๏ธ ๐Ÿ’ช โœ”๏ธ ๐ŸŒ…).
    
    & ๐Ÿ”— ๐Ÿ”ข `get_current_active_user` ๐Ÿ’ช ๐Ÿ“ฃ ๐ŸŽง-๐Ÿ”—, ๐Ÿšซ ๐Ÿ•ด โฎ๏ธ `Depends` โœ‹๏ธ โฎ๏ธ `Security`. ๐Ÿ“ฃ ๐Ÿšฎ ๐Ÿ‘ ๐ŸŽง-๐Ÿ”— ๐Ÿ”ข (`get_current_user`), & ๐ŸŒ– โ†” ๐Ÿ“„.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 11K bytes
    - Viewed (0)
  5. docs/ko/docs/tutorial/dependencies/index.md

    {!> ../../docs_src/dependencies/tutorial001.py!}
    ```
    
    ////
    
    ๋น„๋ก `Body`, `Query` ๋“ฑ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์—ฌ๋Ÿฌ๋ถ„์˜ ํ•จ์ˆ˜์˜ ๋งค๊ฐœ๋ณ€์ˆ˜์— ์žˆ๋Š” `Depends`๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋งŒ, `Depends`๋Š” ์•ฝ๊ฐ„ ๋‹ค๋ฅด๊ฒŒ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.
    
    `Depends`์— ๋‹จ์ผ ๋งค๊ฐœ๋ณ€์ˆ˜๋งŒ ์ „๋‹ฌํ–ˆ์Šต๋‹ˆ๋‹ค.
    
    ์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ํ•จ์ˆ˜๊ฐ™์€ ๊ฒƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    
    ์—ฌ๋Ÿฌ๋ถ„์€ ์ง์ ‘ **ํ˜ธ์ถœํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค** (๋์— ๊ด„ํ˜ธ๋ฅผ ์น˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค), ๋‹จ์ง€ `Depends()`์— ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋„˜๊ฒจ ์คฌ์„ ๋ฟ์ž…๋‹ˆ๋‹ค.
    
    ๊ทธ๋ฆฌ๊ณ  ๊ทธ ํ•จ์ˆ˜๋Š” *๊ฒฝ๋กœ ์ž‘๋™ ํ•จ์ˆ˜*๊ฐ€ ์ž‘๋™ํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ฐ›์Šต๋‹ˆ๋‹ค.
    
    /// tip | "ํŒ"
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 13.5K bytes
    - Viewed (0)
  6. docs_src/settings/app03_an_py39/main.py

    from functools import lru_cache
    
    from fastapi import Depends, FastAPI
    from typing_extensions import Annotated
    
    from . import config
    
    app = FastAPI()
    
    
    @lru_cache
    def get_settings():
        return config.Settings()
    
    
    @app.get("/info")
    async def info(settings: Annotated[config.Settings, Depends(get_settings)]):
        return {
            "app_name": settings.app_name,
            "admin_email": settings.admin_email,
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Oct 24 20:26:06 UTC 2023
    - 462 bytes
    - Viewed (0)
  7. docs_src/dependencies/tutorial011_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    class FixedContentQueryChecker:
        def __init__(self, fixed_content: str):
            self.fixed_content = fixed_content
    
        def __call__(self, q: str = ""):
            if q:
                return self.fixed_content in q
            return False
    
    
    checker = FixedContentQueryChecker("bar")
    
    
    @app.get("/query-checker/")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 544 bytes
    - Viewed (0)
  8. tests/test_dependency_contextvars.py

    from contextvars import ContextVar
    from typing import Any, Awaitable, Callable, Dict, Optional
    
    from fastapi import Depends, FastAPI, Request, Response
    from fastapi.testclient import TestClient
    
    legacy_request_state_context_var: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
        "legacy_request_state_context_var", default=None
    )
    
    app = FastAPI()
    
    
    async def set_up_request_state_dependency():
        request_state = {"user": "deadpond"}
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Feb 17 12:40:12 UTC 2022
    - 1.5K bytes
    - Viewed (0)
  9. tests/test_security_api_key_cookie.py

    from fastapi import Depends, FastAPI, Security
    from fastapi.security import APIKeyCookie
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    app = FastAPI()
    
    api_key = APIKeyCookie(name="key")
    
    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: str = Security(api_key)):
        user = User(username=oauth_header)
        return user
    
    
    @app.get("/users/me")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 1.9K bytes
    - Viewed (0)
  10. tests/test_security_api_key_cookie_description.py

    from fastapi import Depends, FastAPI, Security
    from fastapi.security import APIKeyCookie
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    app = FastAPI()
    
    api_key = APIKeyCookie(name="key", description="An API Cookie Key")
    
    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: str = Security(api_key)):
        user = User(username=oauth_header)
        return user
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.1K bytes
    - Viewed (0)
Back to top