Search Options

Results per page
Sort
Preferred Languages
Advance

Results 181 - 190 of 782 for asyncio (0.04 sec)

  1. docs/es/docs/advanced/events.md

    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    En versiones recientes de Python, también hay un **async context manager**. Lo usarías con `async with`:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    ```
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 8.5K bytes
    - Viewed (0)
  2. docs_src/response_model/tutorial001_py39.py

        price: float
        tax: Union[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},
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Jan 07 13:45:48 UTC 2023
    - 556 bytes
    - Viewed (0)
  3. docs_src/handling_errors/tutorial003_py39.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)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 626 bytes
    - Viewed (0)
  4. tests/test_dependency_contextvars.py

    )
    
    app = FastAPI()
    
    
    async def set_up_request_state_dependency():
        request_state = {"user": "deadpond"}
        contextvar_token = legacy_request_state_context_var.set(request_state)
        yield request_state
        legacy_request_state_context_var.reset(contextvar_token)
    
    
    @app.middleware("http")
    async def custom_middleware(
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.5K bytes
    - Viewed (0)
  5. docs_src/path_operation_configuration/tutorial002_py310.py

        tags: set[str] = set()
    
    
    @app.post("/items/", response_model=Item, tags=["items"])
    async def create_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():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 537 bytes
    - Viewed (0)
  6. 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
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Sep 29 03:29:38 UTC 2025
    - 637 bytes
    - Viewed (0)
  7. docs_src/security/tutorial002_an_py39.py

        return User(
            username=token + "fakedecoded", email="******@****.***", full_name="John Doe"
        )
    
    
    async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):
        user = fake_decode_token(token)
        return user
    
    
    @app.get("/users/me")
    async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 786 bytes
    - Viewed (0)
  8. tests/test_inherited_custom_class.py

        @property  # type: ignore
        def __class__(self):
            return uuid.UUID
    
        @property
        def __dict__(self):
            """Spoof a missing __dict__ by raising TypeError, this is how
            asyncpg.pgroto.pgproto.UUID behaves"""
            raise TypeError("vars() argument must have __dict__ attribute")
    
    
    def test_pydanticv2():
        from pydantic import field_serializer
    
        app = FastAPI()
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 1.8K bytes
    - Viewed (0)
  9. 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):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 816 bytes
    - Viewed (0)
  10. docs_src/response_model/tutorial005_py39.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):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 848 bytes
    - Viewed (0)
Back to top