Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 125 for try (0.17 sec)

  1. docs_src/dependencies/tutorial008_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends
    
    
    async def dependency_a():
        dep_a = generate_dep_a()
        try:
            yield dep_a
        finally:
            dep_a.close()
    
    
    async def dependency_b(dep_a: Annotated[DepA, Depends(dependency_a)]):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 521 bytes
    - Viewed (0)
  2. docs_src/path_operation_advanced_configuration/tutorial007_pv1.py

                "required": True,
            },
        },
    )
    async def create_item(request: Request):
        raw_body = await request.body()
        try:
            data = yaml.safe_load(raw_body)
        except yaml.YAMLError:
            raise HTTPException(status_code=422, detail="Invalid YAML")
        try:
            item = Item.parse_obj(data)
        except ValidationError as e:
            raise HTTPException(status_code=422, detail=e.errors())
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 789 bytes
    - Viewed (0)
  3. SECURITY.md

    I (the author, [@tiangolo](https://twitter.com/tiangolo)) will review it thoroughly and get back to you.
    
    ## Public Discussions
    
    Please restrain from publicly discussing a potential security vulnerability. 🙊
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Sep 11 16:15:49 GMT 2022
    - 1.3K bytes
    - Viewed (0)
  4. docs_src/dependencies/tutorial008.py

    async def dependency_a():
        dep_a = generate_dep_a()
        try:
            yield dep_a
        finally:
            dep_a.close()
    
    
    async def dependency_b(dep_a=Depends(dependency_a)):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    async def dependency_c(dep_b=Depends(dependency_b)):
        dep_c = generate_dep_c()
        try:
            yield dep_c
        finally:
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 455 bytes
    - Viewed (0)
  5. tests/test_dependency_contextmanager.py

    
    async def asyncgen_state_try(state: Dict[str, str] = Depends(get_state)):
        state["/async_raise"] = "asyncgen raise started"
        try:
            yield state["/async_raise"]
        except AsyncDependencyError:
            errors.append("/async_raise")
            raise
        finally:
            state["/async_raise"] = "asyncgen raise finalized"
    
    
    def generator_state_try(state: Dict[str, str] = Depends(get_state)):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  6. docs/en/docs/help-fastapi.md

    Just remember, the most important point is: try to be kind. People come with their frustrations and in many cases don't ask in the best way, but try as best as you can to be kind. 🤗
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 13.7K bytes
    - Viewed (0)
  7. docs_src/dependencies/tutorial008d.py

    from fastapi import Depends, FastAPI, HTTPException
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("We don't swallow the internal error here, we raise again 😎")
            raise
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: str = Depends(get_username)):
        if item_id == "portal-gun":
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 694 bytes
    - Viewed (0)
  8. docs_src/dependencies/tutorial008d_an.py

    from fastapi import Depends, FastAPI, HTTPException
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("We don't swallow the internal error here, we raise again 😎")
            raise
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 744 bytes
    - Viewed (0)
  9. docs_src/dependencies/tutorial008d_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI, HTTPException
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("We don't swallow the internal error here, we raise again 😎")
            raise
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 734 bytes
    - Viewed (0)
  10. docs/en/docs/advanced/websockets.md

    In your WebSocket route you can `await` for messages and send messages.
    
    ```Python hl_lines="48-52"
    {!../../../docs_src/websockets/tutorial001.py!}
    ```
    
    You can receive and send binary, text, and JSON data.
    
    ## Try it
    
    If your file is named `main.py`, run your application with:
    
    <div class="termy">
    
    ```console
    $ fastapi dev main.py
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 02 22:37:31 GMT 2024
    - 6.2K bytes
    - Viewed (0)
Back to top