Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 1,085 for cdef (0.14 sec)

  1. tests/test_dependency_class.py

    
    class CallableDependency:
        def __call__(self, value: str) -> str:
            return value
    
    
    class CallableGenDependency:
        def __call__(self, value: str) -> Generator[str, None, None]:
            yield value
    
    
    class AsyncCallableDependency:
        async def __call__(self, value: str) -> str:
            return value
    
    
    class AsyncCallableGenDependency:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Aug 09 10:54:05 GMT 2020
    - 3.3K bytes
    - Viewed (0)
  2. tests/test_query.py

                ]
            }
        )
    
    
    def test_query_optional():
        response = client.get("/query/optional")
        assert response.status_code == 200
        assert response.json() == "foo bar"
    
    
    def test_query_optional_query_baz():
        response = client.get("/query/optional?query=baz")
        assert response.status_code == 200
        assert response.json() == "foo bar baz"
    
    
    def test_query_optional_not_declared_baz():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 11.4K bytes
    - Viewed (0)
  3. tests/test_validate_response.py

        owner_ids: Optional[List[int]] = None
    
    
    @app.get("/items/invalid", response_model=Item)
    def get_invalid():
        return {"name": "invalid", "price": "foo"}
    
    
    @app.get("/items/invalidnone", response_model=Item)
    def get_invalid_none():
        return None
    
    
    @app.get("/items/validnone", response_model=Union[Item, None])
    def get_valid_none(send_none: bool = False):
        if send_none:
            return None
        else:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 2K bytes
    - Viewed (0)
  4. tests/test_ws_dependencies.py

    from fastapi import APIRouter, Depends, FastAPI, WebSocket
    from fastapi.testclient import TestClient
    from typing_extensions import Annotated
    
    
    def dependency_list() -> List[str]:
        return []
    
    
    DepList = Annotated[List[str], Depends(dependency_list)]
    
    
    def create_dependency(name: str):
        def fun(deps: DepList):
            deps.append(name)
    
        return Depends(fun)
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jun 11 20:35:39 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  5. tests/test_response_by_alias.py

    def by_alias_dict():
        return {"alias": "Foo"}
    
    
    @app.get("/by-alias/model", response_model=Model)
    def by_alias_model():
        return Model(alias="Foo")
    
    
    @app.get("/by-alias/list", response_model=List[Model])
    def by_alias_list():
        return [{"alias": "Foo"}, {"alias": "Bar"}]
    
    
    @app.get("/no-alias/dict", response_model=ModelNoAlias)
    def no_alias_dict():
        return {"name": "Foo"}
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 11.1K bytes
    - Viewed (0)
  6. docs_src/dependency_testing/tutorial001_py310.py

    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    async def common_parameters(q: 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 {"message": "Hello Items!", "params": commons}
    
    
    @app.get("/users/")
    async def read_users(commons: dict = Depends(common_parameters)):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1.4K bytes
    - Viewed (0)
  7. docs_src/security/tutorial004.py

    app = FastAPI()
    
    
    def verify_password(plain_password, hashed_password):
        return pwd_context.verify(plain_password, hashed_password)
    
    
    def get_password_hash(password):
        return pwd_context.hash(password)
    
    
    def get_user(db, username: str):
        if username in db:
            user_dict = db[username]
            return UserInDB(**user_dict)
    
    
    def authenticate_user(fake_db, username: str, password: str):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 4K bytes
    - Viewed (0)
  8. docs_src/security/tutorial004_an.py

    app = FastAPI()
    
    
    def verify_password(plain_password, hashed_password):
        return pwd_context.verify(plain_password, hashed_password)
    
    
    def get_password_hash(password):
        return pwd_context.hash(password)
    
    
    def get_user(db, username: str):
        if username in db:
            user_dict = db[username]
            return UserInDB(**user_dict)
    
    
    def authenticate_user(fake_db, username: str, password: str):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 4.1K bytes
    - Viewed (0)
  9. docs_src/sql_databases/sql_app_py39/crud.py

    from sqlalchemy.orm import Session
    
    from . import models, schemas
    
    
    def get_user(db: Session, user_id: int):
        return db.query(models.User).filter(models.User.id == user_id).first()
    
    
    def get_user_by_email(db: Session, email: str):
        return db.query(models.User).filter(models.User.email == email).first()
    
    
    def get_users(db: Session, skip: int = 0, limit: int = 100):
        return db.query(models.User).offset(skip).limit(limit).all()
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_security/test_tutorial005_an.py

    
    def test_verify_password():
        assert verify_password("secret", fake_users_db["johndoe"]["hashed_password"])
    
    
    def test_get_password_hash():
        assert get_password_hash("secretalice")
    
    
    def test_create_access_token():
        access_token = create_access_token(data={"data": "foo"})
        assert access_token
    
    
    def test_token_no_sub():
        response = client.get(
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 15.4K bytes
    - Viewed (0)
Back to top