Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 111 - 120 of 1,038 for Async (0.02 seconds)

  1. docs_src/response_model/tutorial005_py310.py

    }
    
    
    @app.get(
        "/items/{item_id}/name",
        response_model=Item,
        response_model_include={"name", "description"},
    )
    async def read_item_name(item_id: str):
        return items[item_id]
    
    
    @app.get("/items/{item_id}/public", response_model=Item, response_model_exclude={"tax"})
    async def read_item_public_data(item_id: str):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 816 bytes
    - Click Count (0)
  2. docs_src/path_operation_configuration/tutorial002_py310.py

        tax: float | None = None
        tags: set[str] = set()
    
    
    @app.post("/items/", tags=["items"])
    async def create_item(item: Item) -> Item:
        return item
    
    
    @app.get("/items/", tags=["items"])
    async def read_items():
        return [{"name": "Foo", "price": 42}]
    
    
    @app.get("/users/", tags=["users"])
    async def read_users():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 04 12:07:26 GMT 2026
    - 524 bytes
    - Click Count (0)
  3. docs_src/dependencies/tutorial006_an_py310.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI, Header, HTTPException
    
    app = FastAPI()
    
    
    async def verify_token(x_token: Annotated[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: Annotated[str, Header()]):
        if x_key != "fake-super-secret-key":
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 633 bytes
    - Click Count (0)
  4. tests/test_dependency_pep695.py

    from fastapi.testclient import TestClient
    from typing_extensions import TypeAliasType
    
    
    async def some_value() -> int:
        return 123
    
    
    DependedValue = TypeAliasType(
        "DependedValue", Annotated[int, Depends(some_value)], type_params=()
    )
    
    
    def test_pep695_type_dependencies():
        app = FastAPI()
    
        @app.get("/")
        async def get_with_dep(value: DependedValue) -> str:  # noqa
            return f"value: {value}"
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 05 18:34:34 GMT 2026
    - 628 bytes
    - Click Count (0)
  5. tests/test_route_scope.py

    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    @app.get("/users/{user_id}")
    async def get_user(user_id: str, request: Request):
        route: APIRoute = request.scope["route"]
        return {"user_id": user_id, "path": route.path}
    
    
    @app.websocket("/items/{item_id}")
    async def websocket_item(item_id: str, websocket: WebSocket):
        route: APIWebSocketRoute = websocket.scope["route"]
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Sep 29 03:29:38 GMT 2025
    - 1.5K bytes
    - Click Count (0)
  6. docs_src/response_model/tutorial001_py310.py

        description: str | None = None
        price: float
        tax: float | None = None
        tags: list[str] = []
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item) -> Any:
        return item
    
    
    @app.get("/items/", response_model=list[Item])
    async def read_items() -> Any:
        return [
            {"name": "Portal Gun", "price": 42.0},
            {"name": "Plumbus", "price": 32.0},
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Jan 07 13:45:48 GMT 2023
    - 537 bytes
    - Click Count (0)
  7. tests/test_starlette_exception.py

    
    @app.get("/items/{item_id}")
    async def read_item(item_id: str):
        if item_id not in items:
            raise HTTPException(
                status_code=404,
                detail="Item not found",
                headers={"X-Error": "Some custom header"},
            )
        return {"item": items[item_id]}
    
    
    @app.get("/http-no-body-statuscode-exception")
    async def no_body_status_code_exception():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 8.1K bytes
    - Click Count (0)
  8. docs_src/handling_errors/tutorial006_py310.py

    app = FastAPI()
    
    
    @app.exception_handler(StarletteHTTPException)
    async def custom_http_exception_handler(request, exc):
        print(f"OMG! An HTTP error!: {repr(exc)}")
        return await http_exception_handler(request, exc)
    
    
    @app.exception_handler(RequestValidationError)
    async def validation_exception_handler(request, exc):
        print(f"OMG! The client sent invalid data!: {exc}")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 928 bytes
    - Click Count (0)
  9. docs_src/app_testing/tutorial002_py310.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from fastapi.websockets import WebSocket
    
    app = FastAPI()
    
    
    @app.get("/")
    async def read_main():
        return {"msg": "Hello World"}
    
    
    @app.websocket("/ws")
    async def websocket(websocket: WebSocket):
        await websocket.accept()
        await websocket.send_json({"msg": "Hello WebSocket"})
        await websocket.close()
    
    
    def test_read_main():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 757 bytes
    - Click Count (0)
  10. tests/test_dependency_duplicates.py

    ):
        return [item, sub_item]
    
    
    @app.post("/with-duplicates")
    async def with_duplicates(item: Item, item2: Item = Depends(duplicate_dependency)):
        return [item, item2]
    
    
    @app.post("/no-duplicates")
    async def no_duplicates(item: Item, item2: Item = Depends(dependency)):
        return [item, item2]
    
    
    @app.post("/with-duplicates-sub")
    async def no_duplicates_sub(
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 8.8K bytes
    - Click Count (0)
Back to Top