Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 101 - 110 of 1,038 for Async (1.06 seconds)

  1. docs_src/response_model/tutorial006_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/bigger_applications/app_an_py310/dependencies.py

    from typing import Annotated
    
    from fastapi import Header, HTTPException
    
    
    async def get_token_header(x_token: Annotated[str, Header()]):
        if x_token != "fake-super-secret-token":
            raise HTTPException(status_code=400, detail="X-Token header invalid")
    
    
    async def get_query_token(token: str):
        if token != "jessica":
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 409 bytes
    - Click Count (0)
  3. docs_src/generate_clients/tutorial001_py310.py

        name: str
        price: float
    
    
    class ResponseMessage(BaseModel):
        message: str
    
    
    @app.post("/items/", response_model=ResponseMessage)
    async def create_item(item: Item):
        return {"message": "item received"}
    
    
    @app.get("/items/", response_model=list[Item])
    async def get_items():
        return [
            {"name": "Plumbus", "price": 3},
            {"name": "Portal Gun", "price": 9001},
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 494 bytes
    - Click Count (0)
  4. docs/en/docs/advanced/stream-data.md

    ### Files and Async { #files-and-async }
    
    In most cases, file-like objects are not compatible with async and await by default.
    
    For example, they don't have an `await file.read()`, or `async for chunk in file`.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 5.4K bytes
    - Click Count (0)
  5. docs_src/websockets_/tutorial002_an_py310.py

                    input.value = ''
                    event.preventDefault()
                }
            </script>
        </body>
    </html>
    """
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    async def get_cookie_or_token(
        websocket: WebSocket,
        session: Annotated[str | None, Cookie()] = None,
        token: Annotated[str | None, Query()] = None,
    ):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 12:34:37 GMT 2026
    - 2.8K bytes
    - Click Count (0)
  6. docs_src/body_updates/tutorial002_py310.py

        "baz": {"name": "Baz", "description": None, "price": 50.2, "tax": 10.5, "tags": []},
    }
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_item(item_id: str):
        return items[item_id]
    
    
    @app.patch("/items/{item_id}")
    async def update_item(item_id: str, item: Item) -> Item:
        stored_item_data = items[item_id]
        stored_item_model = Item(**stored_item_data)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 04 12:07:26 GMT 2026
    - 1009 bytes
    - Click Count (0)
  7. docs/en/docs/tutorial/server-sent-events.md

    ///
    
    ### Non-async *path operation functions* { #non-async-path-operation-functions }
    
    You can also use regular `def` functions (without `async`), and use `yield` the same way.
    
    FastAPI will make sure it's run correctly so that it doesn't block the event loop.
    
    As in this case the function is not async, the right return type would be `Iterable[Item]`:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 4.6K bytes
    - Click Count (0)
  8. fastapi/middleware/asyncexitstack.py

        def __init__(
            self, app: ASGIApp, context_name: str = "fastapi_middleware_astack"
        ) -> None:
            self.app = app
            self.context_name = context_name
    
        async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
            async with AsyncExitStack() as stack:
                scope[self.context_name] = stack
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Sep 29 03:29:38 GMT 2025
    - 637 bytes
    - Click Count (0)
  9. docs_src/handling_errors/tutorial003_py310.py

    
    app = FastAPI()
    
    
    @app.exception_handler(UnicornException)
    async def unicorn_exception_handler(request: Request, exc: UnicornException):
        return JSONResponse(
            status_code=418,
            content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
        )
    
    
    @app.get("/unicorns/{name}")
    async def read_unicorn(name: str):
        if name == "yolo":
            raise UnicornException(name=name)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 626 bytes
    - Click Count (0)
  10. docs_src/custom_request_and_route/tutorial002_py310.py

    from fastapi.routing import APIRoute
    
    
    class ValidationErrorLoggingRoute(APIRoute):
        def get_route_handler(self) -> Callable:
            original_route_handler = super().get_route_handler()
    
            async def custom_route_handler(request: Request) -> Response:
                try:
                    return await original_route_handler(request)
                except RequestValidationError as exc:
                    body = await request.body()
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 10 08:55:32 GMT 2025
    - 935 bytes
    - Click Count (0)
Back to Top