Search Options

Results per page
Sort
Preferred Languages
Advance

Results 251 - 260 of 1,379 for def2 (0.02 sec)

  1. tests/test_tutorial/test_cookie_param_models/test_tutorial002.py

            pytest.param("tutorial002_pv1_an_py310", marks=[needs_py310, needs_pydanticv1]),
        ],
    )
    def get_client(request: pytest.FixtureRequest):
        mod = importlib.import_module(f"docs_src.cookie_param_models.{request.param}")
    
        client = TestClient(mod.app)
        return client
    
    
    def test_cookie_param_model(client: TestClient):
        with client as c:
            c.cookies.set("session_id", "123")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 8.6K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_request_files/test_tutorial002.py

        assert response.json() == {"filenames": ["test.txt", "test2.txt"]}
    
    
    def test_get_root():
        client = TestClient(app)
        response = client.get("/")
        assert response.status_code == 200, response.text
        assert b"<form" in response.content
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 8.5K bytes
    - Viewed (0)
  3. tests/test_security_http_basic_optional.py

    security = HTTPBasic(auto_error=False)
    
    
    @app.get("/users/me")
    def read_current_user(credentials: Optional[HTTPBasicCredentials] = Security(security)):
        if credentials is None:
            return {"msg": "Create an account first"}
        return {"username": credentials.username, "password": credentials.password}
    
    
    client = TestClient(app)
    
    
    def test_security_http_basic():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.6K bytes
    - Viewed (0)
  4. fastapi/security/oauth2.py

        ```python
        from typing import Annotated
    
        from fastapi import Depends, FastAPI
        from fastapi.security import OAuth2PasswordRequestForm
    
        app = FastAPI()
    
    
        @app.post("/login")
        def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):
            data = {}
            data["scopes"] = []
            for scope in form_data.scopes:
                data["scopes"].append(scope)
            if form_data.client_id:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 23 18:30:18 UTC 2024
    - 21.1K bytes
    - Viewed (0)
  5. docs_src/request_files/tutorial003_an_py39.py

    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_files(
        files: Annotated[list[bytes], File(description="Multiple files as bytes")],
    ):
        return {"file_sizes": [len(file) for file in files]}
    
    
    @app.post("/uploadfiles/")
    async def create_upload_files(
        files: Annotated[
            list[UploadFile], File(description="Multiple files as UploadFile")
        ],
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 952 bytes
    - Viewed (0)
  6. docs_src/dependencies/tutorial008.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=Depends(dependency_a)):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    async def dependency_c(dep_b=Depends(dependency_b)):
        dep_c = generate_dep_c()
        try:
            yield dep_c
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 455 bytes
    - Viewed (0)
  7. docs_src/dependencies/tutorial009.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=Depends(dependency_a)):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    async def dependency_c(dep_b=Depends(dependency_b)):
        dep_c = generate_dep_c()
        try:
            yield dep_c
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 455 bytes
    - Viewed (0)
  8. docs_src/bigger_applications/app_an/routers/users.py

    router = APIRouter()
    
    
    @router.get("/users/", tags=["users"])
    async def read_users():
        return [{"username": "Rick"}, {"username": "Morty"}]
    
    
    @router.get("/users/me", tags=["users"])
    async def read_user_me():
        return {"username": "fakecurrentuser"}
    
    
    @router.get("/users/{username}", tags=["users"])
    async def read_user(username: str):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 407 bytes
    - Viewed (0)
  9. tests/test_tutorial/test_schema_extra_example/test_tutorial001_py310_pv1.py

    from fastapi.testclient import TestClient
    
    from ...utils import needs_py310, needs_pydanticv1
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.schema_extra_example.tutorial001_py310_pv1 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py310
    @needs_pydanticv1
    def test_post_body_example(client: TestClient):
        response = client.put(
            "/items/5",
            json={
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 4.5K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_header_params/test_tutorial002_py310.py

                200,
                {"strange_header": None},
            ),
        ],
    )
    def test(path, headers, expected_status, expected_response, client: TestClient):
        response = client.get(path, headers=headers)
        assert response.status_code == expected_status
        assert response.json() == expected_response
    
    
    @needs_py310
    def test_openapi_schema():
        from docs_src.header_params.tutorial002_py310 import app
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 4.2K bytes
    - Viewed (0)
Back to top