Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 147 for Krause (0.14 sec)

  1. docs_src/handling_errors/tutorial002.py

    from fastapi import FastAPI, HTTPException
    
    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items-header/{item_id}")
    async def read_item_header(item_id: str):
        if item_id not in items:
            raise HTTPException(
                status_code=404,
                detail="Item not found",
                headers={"X-Error": "There goes my error"},
            )
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 404 bytes
    - Viewed (0)
  2. docs/em/docs/tutorial/handling-errors.md

    โžก๏ธ ๐Ÿ’ฌ ๐Ÿ‘† โœ”๏ธ ๐Ÿ›ƒ โš  `UnicornException` ๐Ÿ‘ˆ ๐Ÿ‘† (โš–๏ธ ๐Ÿ—ƒ ๐Ÿ‘† โš™๏ธ) ๐Ÿ’ช `raise`.
    
    & ๐Ÿ‘† ๐Ÿ’š ๐Ÿต ๐Ÿ‘‰ โš  ๐ŸŒ โฎ๏ธ FastAPI.
    
    ๐Ÿ‘† ๐Ÿ’ช ๐Ÿšฎ ๐Ÿ›ƒ โš  ๐Ÿ•โ€๐Ÿฆบ โฎ๏ธ `@app.exception_handler()`:
    
    ```Python hl_lines="5-7  13-18  24"
    {!../../../docs_src/handling_errors/tutorial003.py!}
    ```
    
    ๐Ÿ“ฅ, ๐Ÿšฅ ๐Ÿ‘† ๐Ÿ“จ `/unicorns/yolo`, *โžก ๐Ÿ› ๏ธ* ๐Ÿ”œ `raise` `UnicornException`.
    
    โœ‹๏ธ โšซ๏ธ ๐Ÿ”œ ๐Ÿต `unicorn_exception_handler`.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.3K bytes
    - Viewed (0)
  3. docs_src/handling_errors/tutorial006.py

        print(f"OMG! The client sent invalid data!: {exc}")
        return await request_validation_exception_handler(request, exc)
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: int):
        if item_id == 3:
            raise HTTPException(status_code=418, detail="Nope! I don't like 3.")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Aug 09 11:10:33 GMT 2020
    - 928 bytes
    - Viewed (0)
  4. docs_src/security/tutorial007_an.py

        correct_password_bytes = b"swordfish"
        is_correct_password = secrets.compare_digest(
            current_password_bytes, correct_password_bytes
        )
        if not (is_correct_username and is_correct_password):
            raise HTTPException(
                status_code=status.HTTP_401_UNAUTHORIZED,
                detail="Incorrect username or password",
                headers={"WWW-Authenticate": "Basic"},
            )
        return credentials.username
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 1.2K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_dependencies/test_tutorial008d_an.py

            exc_info.value.args[0] == "The portal gun is too dangerous to be owned by Rick"
        )
    
    
    def test_internal_server_error():
        from docs_src.dependencies.tutorial008d_an import app
    
        client = TestClient(app, raise_server_exceptions=False)
        response = client.get("/items/portal-gun")
        assert response.status_code == 500, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.2K bytes
    - Viewed (0)
  6. docs/ja/docs/tutorial/handling-errors.md

    ใ‚ใชใŸ๏ผˆใพใŸใฏไฝฟ็”จใ—ใฆใ„ใ‚‹ใƒฉใ‚คใƒ–ใƒฉใƒช๏ผ‰ใŒ`raise`ใ™ใ‚‹ใ‹ใ‚‚ใ—ใ‚Œใชใ„ใ‚ซใ‚นใ‚ฟใƒ ไพ‹ๅค–`UnicornException`ใŒใ‚ใ‚‹ใจใ—ใพใ—ใ‚‡ใ†ใ€‚
    
    ใใ—ใฆใ€ใ“ใฎไพ‹ๅค–ใ‚’FastAPIใงใ‚ฐใƒญใƒผใƒใƒซใซๅ‡ฆ็†ใ—ใŸใ„ใจๆ€ใ„ใพใ™ใ€‚
    
    ใ‚ซใ‚นใ‚ฟใƒ ไพ‹ๅค–ใƒใƒณใƒ‰ใƒฉใ‚’`@app.exception_handler()`ใง่ฟฝๅŠ ใ™ใ‚‹ใ“ใจใŒใงใใพใ™:
    
    ```Python hl_lines="5 6 7  13 14 15 16 17 18  24"
    {!../../../docs_src/handling_errors/tutorial003.py!}
    ```
    
    ใ“ใ“ใงใ€`/unicorns/yolo`ใ‚’ใƒชใ‚ฏใ‚จใ‚นใƒˆใ™ใ‚‹ใจใ€*path operation*ใฏ`UnicornException`ใ‚’`raise`ใ—ใพใ™ใ€‚
    
    ใ—ใ‹ใ—ใ€ใ“ใ‚Œใฏ`unicorn_exception_handler`ใงๅ‡ฆ็†ใ•ใ‚Œใพใ™ใ€‚
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 11.8K bytes
    - Viewed (0)
  7. docs_src/websockets/tutorial002_an_py310.py

    
    async def get_cookie_or_token(
        websocket: WebSocket,
        session: Annotated[str | None, Cookie()] = None,
        token: Annotated[str | None, Query()] = None,
    ):
        if session is None and token is None:
            raise WebSocketException(code=status.WS_1008_POLICY_VIOLATION)
        return session or token
    
    
    @app.websocket("/items/{item_id}/ws")
    async def websocket_endpoint(
        *,
        websocket: WebSocket,
        item_id: str,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.8K bytes
    - Viewed (0)
  8. fastapi/security/oauth2.py

        async def __call__(self, request: Request) -> Optional[str]:
            authorization = request.headers.get("Authorization")
            if not authorization:
                if self.auto_error:
                    raise HTTPException(
                        status_code=HTTP_403_FORBIDDEN, detail="Not authenticated"
                    )
                else:
                    return None
            return authorization
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 21.1K bytes
    - Viewed (1)
  9. docs/zh/docs/tutorial/handling-errors.md

    ```
    
    ### ่งฆๅ‘ `HTTPException`
    
    `HTTPException` ๆ˜ฏ้ขๅค–ๅŒ…ๅซไบ†ๅ’Œ API ๆœ‰ๅ…ณๆ•ฐๆฎ็š„ๅธธ่ง„ Python ๅผ‚ๅธธใ€‚
    
    ๅ› ไธบๆ˜ฏ Python ๅผ‚ๅธธ๏ผŒๆ‰€ไปฅไธ่ƒฝ `return`๏ผŒๅช่ƒฝ `raise`ใ€‚
    
    ๅฆ‚ๅœจ่ฐƒ็”จ*่ทฏๅพ„ๆ“ไฝœๅ‡ฝๆ•ฐ*้‡Œ็š„ๅทฅๅ…ทๅ‡ฝๆ•ฐๆ—ถ๏ผŒ่งฆๅ‘ไบ† `HTTPException`๏ผŒFastAPI ๅฐฑไธๅ†็ปง็ปญๆ‰ง่กŒ*่ทฏๅพ„ๆ“ไฝœๅ‡ฝๆ•ฐ*ไธญ็š„ๅŽ็ปญไปฃ็ ๏ผŒ่€Œๆ˜ฏ็ซ‹ๅณ็ปˆๆญข่ฏทๆฑ‚๏ผŒๅนถๆŠŠ `HTTPException` ็š„ HTTP ้”™่ฏฏๅ‘้€่‡ณๅฎขๆˆท็ซฏใ€‚
    
    ๅœจไป‹็ปไพ่ต–้กนไธŽๅฎ‰ๅ…จ็š„็ซ ่Š‚ไธญ๏ผŒๆ‚จๅฏไปฅไบ†่งฃๆ›ดๅคš็”จ `raise` ๅผ‚ๅธธไปฃๆ›ฟ `return` ๅ€ผ็š„ไผ˜ๅŠฟใ€‚
    
    ๆœฌไพ‹ไธญ๏ผŒๅฎขๆˆท็ซฏ็”จ `ID` ่ฏทๆฑ‚็š„ `item` ไธๅญ˜ๅœจๆ—ถ๏ผŒ่งฆๅ‘็Šถๆ€็ ไธบ `404` ็š„ๅผ‚ๅธธ๏ผš
    
    ```Python hl_lines="11"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.4K bytes
    - Viewed (0)
  10. docs/em/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md

    ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ ๐ŸŽ ๐Ÿ”— *๐Ÿ”ข* ๐Ÿ‘† โš™๏ธ ๐Ÿ›Ž.
    
    ### ๐Ÿ”— ๐Ÿ“„
    
    ๐Ÿ‘ซ ๐Ÿ’ช ๐Ÿ“ฃ ๐Ÿ“จ ๐Ÿ“„ (๐Ÿ’– ๐ŸŽš) โš–๏ธ ๐ŸŽ ๐ŸŽง-๐Ÿ”—:
    
    ```Python hl_lines="6  11"
    {!../../../docs_src/dependencies/tutorial006.py!}
    ```
    
    ### ๐Ÿคš โš 
    
    ๐Ÿ‘ซ ๐Ÿ”— ๐Ÿ’ช `raise` โš , ๐ŸŽ ๐Ÿ˜ ๐Ÿ”—:
    
    ```Python hl_lines="8  13"
    {!../../../docs_src/dependencies/tutorial006.py!}
    ```
    
    ### ๐Ÿ“จ ๐Ÿ’ฒ
    
    & ๐Ÿ‘ซ ๐Ÿ’ช ๐Ÿ“จ ๐Ÿ’ฒ โš–๏ธ ๐Ÿšซ, ๐Ÿ’ฒ ๐Ÿ† ๐Ÿšซ โš™๏ธ.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Apr 01 09:26:04 GMT 2023
    - 2.2K bytes
    - Viewed (0)
Back to top