Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 51 - 60 of 835 for Async (0.27 seconds)

The search processing time has exceeded the limit. The displayed results may be partial.

  1. tests/test_http_connection_injection.py

    from starlette.websockets import WebSocket
    
    app = FastAPI()
    app.state.value = 42
    
    
    async def extract_value_from_http_connection(conn: HTTPConnection):
        return conn.app.state.value
    
    
    @app.get("/http")
    async def get_value_by_http(value: int = Depends(extract_value_from_http_connection)):
        return value
    
    
    @app.websocket("/ws")
    async def get_value_by_ws(
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Aug 09 13:56:41 GMT 2020
    - 972 bytes
    - Click Count (0)
  2. docs_src/bigger_applications/app_an_py310/routers/items.py

        responses={404: {"description": "Not found"}},
    )
    
    
    fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
    
    
    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 1011 bytes
    - Click Count (0)
  3. docs_src/custom_request_and_route/tutorial003_py310.py

                return response
    
            return custom_route_handler
    
    
    app = FastAPI()
    router = APIRouter(route_class=TimedRoute)
    
    
    @app.get("/")
    async def not_timed():
        return {"message": "Not timed"}
    
    
    @router.get("/timed")
    async def timed():
        return {"message": "It's the time of my life"}
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 10 08:55:32 GMT 2025
    - 1K bytes
    - Click Count (0)
  4. tests/test_annotated.py

    from inline_snapshot import snapshot
    
    app = FastAPI()
    
    
    @app.get("/default")
    async def default(foo: Annotated[str, Query()] = "foo"):
        return {"foo": foo}
    
    
    @app.get("/required")
    async def required(foo: Annotated[str, Query(min_length=1)]):
        return {"foo": foo}
    
    
    @app.get("/multiple")
    async def multiple(foo: Annotated[str, object(), Query(min_length=1)]):
        return {"foo": foo}
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 10.5K bytes
    - Click Count (0)
  5. tests/test_dependency_overrides.py

    app = FastAPI()
    
    router = APIRouter()
    
    
    async def common_parameters(q: str, skip: int = 0, limit: int = 100):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/main-depends/")
    async def main_depends(commons: dict = Depends(common_parameters)):
        return {"in": "main-depends", "params": commons}
    
    
    @app.get("/decorator-depends/", dependencies=[Depends(common_parameters)])
    async def decorator_depends():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 11.2K bytes
    - Click Count (0)
  6. docs_src/generate_clients/tutorial002_py310.py

    async def create_item(item: Item):
        return {"message": "Item received"}
    
    
    @app.get("/items/", response_model=list[Item], tags=["items"])
    async def get_items():
        return [
            {"name": "Plumbus", "price": 3},
            {"name": "Portal Gun", "price": 9001},
        ]
    
    
    @app.post("/users/", response_model=ResponseMessage, tags=["users"])
    async def create_user(user: User):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 730 bytes
    - Click Count (0)
  7. fastapi/.agents/skills/fastapi/references/streaming.md

    # Streaming
    
    ## Stream JSON Lines
    
    To stream JSON Lines, declare the return type and use `yield` to return the data.
    
    ```python
    @app.get("/items/stream")
    async def stream_items() -> AsyncIterable[Item]:
        for item in items:
            yield item
    ```
    
    ## Server-Sent Events (SSE)
    
    To stream Server-Sent Events, use `response_class=EventSourceResponse` and `yield` items from the endpoint.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 10:05:57 GMT 2026
    - 2.5K bytes
    - Click Count (0)
  8. docs_src/request_files/tutorial002_an_py310.py

    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_files(files: Annotated[list[bytes], File()]):
        return {"file_sizes": [len(file) for file in files]}
    
    
    @app.post("/uploadfiles/")
    async def create_upload_files(files: list[UploadFile]):
        return {"filenames": [file.filename for file in files]}
    
    
    @app.get("/")
    async def main():
        content = """
    <body>
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 826 bytes
    - Click Count (0)
  9. docs_src/security/tutorial004_an_py310.py

        if user is None:
            raise credentials_exception
        return user
    
    
    async def get_current_active_user(
        current_user: Annotated[User, Depends(get_current_user)],
    ):
        if current_user.disabled:
            raise HTTPException(status_code=400, detail="Inactive user")
        return current_user
    
    
    @app.post("/token")
    async def login_for_access_token(
        form_data: Annotated[OAuth2PasswordRequestForm, Depends()],
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 18:10:35 GMT 2026
    - 4.2K bytes
    - Click Count (0)
  10. docs_src/request_files/tutorial003_an_py310.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")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 952 bytes
    - Click Count (0)
Back to Top