Search Options

Results per page
Sort
Preferred Languages
Advance

Results 181 - 190 of 1,379 for def2 (0.05 sec)

  1. tests/test_tutorial/test_websockets/test_tutorial002_an_py310.py

    
    @pytest.fixture(name="app")
    def get_app():
        from docs_src.websockets.tutorial002_an_py310 import app
    
        return app
    
    
    @needs_py310
    def test_main(app: FastAPI):
        client = TestClient(app)
        response = client.get("/")
        assert response.status_code == 200, response.text
        assert b"<!DOCTYPE html>" in response.content
    
    
    @needs_py310
    def test_websocket_with_cookie(app: FastAPI):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 3.9K bytes
    - Viewed (0)
  2. tests/test_dependency_duplicates.py

    
    class Item(BaseModel):
        data: str
    
    
    def duplicate_dependency(item: Item):
        return item
    
    
    def dependency(item2: Item):
        return item2
    
    
    def sub_duplicate_dependency(
        item: Item, sub_item: Item = Depends(duplicate_dependency)
    ):
        return [item, sub_item]
    
    
    @app.post("/with-duplicates")
    async def with_duplicates(item: Item, item2: Item = Depends(duplicate_dependency)):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 8.4K bytes
    - Viewed (0)
  3. docs_src/bigger_applications/app_an_py39/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)
  4. tests/test_tutorial/test_body_multiple_params/test_tutorial001_an.py

    import pytest
    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.body_multiple_params.tutorial001_an import app
    
        client = TestClient(app)
        return client
    
    
    def test_post_body_q_bar_content(client: TestClient):
        response = client.put("/items/5?q=bar", json={"name": "Foo", "price": 50.5})
        assert response.status_code == 200
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:40:57 UTC 2024
    - 7.5K bytes
    - Viewed (0)
  5. docs_src/dependencies/tutorial012.py

    from fastapi import Depends, FastAPI, Header, HTTPException
    
    
    async def verify_token(x_token: str = Header()):
        if x_token != "fake-super-secret-token":
            raise HTTPException(status_code=400, detail="X-Token header invalid")
    
    
    async def verify_key(x_key: str = Header()):
        if x_key != "fake-super-secret-key":
            raise HTTPException(status_code=400, detail="X-Key header invalid")
        return x_key
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 696 bytes
    - Viewed (0)
  6. tests/test_custom_schema_fields.py

            "name": {
                "title": "Name",
                "type": "string",
            }
        },
    }
    
    
    def test_custom_response_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json()["components"]["schemas"]["Item"] == item_schema
    
    
    def test_response():
        # For coverage
        response = client.get("/foo")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 1.2K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_query_params_str_validations/test_tutorial014_an_py310.py

    import pytest
    from fastapi.testclient import TestClient
    
    from ...utils import needs_py310
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.query_params_str_validations.tutorial014_an_py310 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py310
    def test_hidden_query(client: TestClient):
        response = client.get("/items?hidden_query=somevalue")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 3.1K bytes
    - Viewed (0)
  8. docs_src/security/tutorial004_py310.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):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4K bytes
    - Viewed (0)
  9. docs_src/security/tutorial005_py310.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):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 5.1K bytes
    - Viewed (0)
  10. tests/test_no_swagger_ui_redirect.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    
    app = FastAPI(swagger_ui_oauth2_redirect_url=None)
    
    
    @app.get("/items/")
    async def read_items():
        return {"id": "foo"}
    
    
    client = TestClient(app)
    
    
    def test_swagger_ui():
        response = client.get("/docs")
        assert response.status_code == 200, response.text
        assert response.headers["content-type"] == "text/html; charset=utf-8"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Apr 08 04:37:38 UTC 2020
    - 786 bytes
    - Viewed (0)
Back to top