Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 24 for handlebars (0.36 sec)

  1. docs/en/docs/advanced/testing-events.md

    # Testing Events: startup - shutdown
    
    When you need your event handlers (`startup` and `shutdown`) to run in your tests, you can use the `TestClient` with a `with` statement:
    
    ```Python hl_lines="9-12  20-24"
    {!../../../docs_src/app_testing/tutorial003.py!}
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Aug 29 14:02:58 GMT 2020
    - 262 bytes
    - Viewed (0)
  2. docs_src/handling_errors/tutorial006.py

    from fastapi import FastAPI, HTTPException
    from fastapi.exception_handlers import (
        http_exception_handler,
        request_validation_exception_handler,
    )
    from fastapi.exceptions import RequestValidationError
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    app = FastAPI()
    
    
    @app.exception_handler(StarletteHTTPException)
    async def custom_http_exception_handler(request, exc):
        print(f"OMG! An HTTP error!: {repr(exc)}")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Aug 09 11:10:33 GMT 2020
    - 928 bytes
    - Viewed (0)
  3. docs/en/docs/advanced/middleware.md

    new_app = UnicornMiddleware(app, some_config="rainbow")
    ```
    
    But FastAPI (actually Starlette) provides a simpler way to do it that makes sure that the internal middlewares to handle server errors and custom exception handlers work properly.
    
    For that, you use `app.add_middleware()` (as in the example for CORS).
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 10 18:27:10 GMT 2023
    - 4K bytes
    - Viewed (0)
  4. docs/zh/docs/tutorial/handling-errors.md

    ```Python
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    ```
    
    ### 复用 **FastAPI** 异常处理器
    
    FastAPI 支持先对异常进行某些处理,然后再使用 **FastAPI** 中处理该异常的默认异常处理器。
    
    从 `fastapi.exception_handlers` 中导入要复用的默认异常处理器:
    
    ```Python hl_lines="2-5  15  21"
    {!../../../docs_src/handling_errors/tutorial006.py!}
    
    ```
    
    虽然,本例只是输出了夸大其词的错误信息。
    
    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)
  5. docs/em/docs/tutorial/handling-errors.md

    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### 🏤-⚙️ **FastAPI**'Ⓜ ⚠ 🐕‍🦺
    
    🚥 👆 💚 ⚙️ ⚠ ⤴️ ⏮️ 🎏 🔢 ⚠ 🐕‍🦺 ⚪️➡️ **FastAPI**, 👆 💪 🗄 & 🏤-⚙️ 🔢 ⚠ 🐕‍🦺 ⚪️➡️ `fastapi.exception_handlers`:
    
    ```Python hl_lines="2-5  15  21"
    {!../../../docs_src/handling_errors/tutorial006.py!}
    ```
    
    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)
  6. docs/ja/docs/tutorial/handling-errors.md

    from starlette.exceptions import HTTPException as StarletteHTTPException
    ```
    
    ### **FastAPI** の例外ハンドラの再利用
    
    また、何らかの方法で例外を使用することもできますが、**FastAPI** から同じデフォルトの例外ハンドラを使用することもできます。
    
    デフォルトの例外ハンドラを`fastapi.exception_handlers`からインポートして再利用することができます:
    
    ```Python hl_lines="2 3 4 5 15 21"
    {!../../../docs_src/handling_errors/tutorial006.py!}
    ```
    
    この例では、非常に表現力のあるメッセージでエラーを`print`しています。
    
    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. tests/test_starlette_exception.py

        assert response.json() == {"detail": "Item not found"}
    
    
    def test_no_body_status_code_exception_handlers():
        response = client.get("/http-no-body-statuscode-exception")
        assert response.status_code == 204
        assert not response.content
    
    
    def test_no_body_status_code_with_detail_exception_handlers():
        response = client.get("/http-no-body-statuscode-with-detail-exception")
        assert response.status_code == 204
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 7.4K bytes
    - Viewed (0)
  8. tests/test_ws_router.py

        """
    
        async def custom_handler(websocket: WebSocket, exc: CustomError) -> None:
            await websocket.close(1002, "foo")
    
        myapp = make_app(exception_handlers={CustomError: custom_handler})
        client = TestClient(myapp)
        with pytest.raises(WebSocketDisconnect) as e:
            with client.websocket_connect("/custom_error/"):
                pass  # pragma: no cover
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  9. docs/en/docs/how-to/async-sql-encode-databases.md

    So, you will be able to see it all in the interactive API docs.
    
    ## Connect and disconnect
    
    * Create your `FastAPI` application.
    * Create event handlers to connect and disconnect from the database.
    
    ```Python hl_lines="42  45-47  50-52"
    {!../../../docs_src/async_sql_databases/tutorial001.py!}
    ```
    
    ## Read notes
    
    Create the *path operation function* to read notes:
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 5.3K bytes
    - Viewed (0)
  10. docs/en/docs/release-notes.md

            * [Override the default exception handlers](https://fastapi.tiangolo.com/tutorial/handling-errors/#override-the-default-exception-handlers).
            * [Re-use **FastAPI's** exception handlers](https://fastapi.tiangolo.com/tutorial/handling-errors/#re-use-fastapis-exception-handlers).
        * PR [#273](https://github.com/tiangolo/fastapi/pull/273).
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri May 03 23:25:42 GMT 2024
    - 388.1K bytes
    - Viewed (1)
Back to top