Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 15 for rainbows (0.07 sec)

  1. docs/em/docs/advanced/middleware.md

    app = SomeASGIApp()
    
    new_app = UnicornMiddleware(app, some_config="rainbow")
    ```
    
    ✋️ FastAPI (🤙 💃) 🚚 🙅 🌌 ⚫️ 👈 ⚒ 💭 👈 🔗 🛠️ 🍵 💽 ❌ & 🛃 ⚠ 🐕‍🦺 👷 ☑.
    
    👈, 👆 ⚙️ `app.add_middleware()` (🖼 ⚜).
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    app.add_middleware(UnicornMiddleware, some_config="rainbow")
    ```
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.2K bytes
    - Viewed (0)
  2. docs_src/handling_errors/tutorial003.py

    @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 Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 626 bytes
    - Viewed (0)
  3. docs/de/docs/advanced/middleware.md

    ```Python
    from unicorn import UnicornMiddleware
    
    app = SomeASGIApp()
    
    new_app = UnicornMiddleware(app, some_config="rainbow")
    ```
    
    Aber FastAPI (eigentlich Starlette) bietet eine einfachere Möglichkeit, welche sicherstellt, dass die internen Middlewares zur Behandlung von Serverfehlern und benutzerdefinierten Exceptionhandlern ordnungsgemäß funktionieren.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 4.3K bytes
    - Viewed (0)
  4. docs/pt/docs/advanced/middleware.md

    ```Python
    from unicorn import UnicornMiddleware
    
    app = SomeASGIApp()
    
    new_app = UnicornMiddleware(app, some_config="rainbow")
    ```
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 30 20:00:22 UTC 2024
    - 4.3K bytes
    - Viewed (0)
  5. docs/en/docs/advanced/middleware.md

    ```Python
    from unicorn import UnicornMiddleware
    
    app = SomeASGIApp()
    
    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 handle server errors and custom exception handlers work properly.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 27 16:45:50 UTC 2024
    - 4K bytes
    - Viewed (0)
  6. docs/zh/docs/advanced/middleware.md

    app = SomeASGIApp()
    
    new_app = UnicornMiddleware(app, some_config="rainbow")
    ```
    
    但 FastAPI(实际上是 Starlette)提供了一种更简单的方式,能让内部中间件在处理服务器错误的同时,还能让自定义异常处理器正常运作。
    
    为此,要使用 `app.add_middleware()` (与 CORS 中的示例一样)。
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    app.add_middleware(UnicornMiddleware, some_config="rainbow")
    ```
    
    `app.add_middleware()` 的第一个参数是中间件的类,其它参数则是要传递给中间件的参数。
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.5K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_handling_errors/test_tutorial003.py

    
    def test_get_exception():
        response = client.get("/unicorns/yolo")
        assert response.status_code == 418, response.text
        assert response.json() == {
            "message": "Oops! yolo did something. There goes a rainbow..."
        }
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json() == {
            "openapi": "3.1.0",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 3.2K bytes
    - Viewed (0)
  8. docs/em/docs/tutorial/handling-errors.md

    ✋️ ⚫️ 🔜 🍵 `unicorn_exception_handler`.
    
    , 👆 🔜 📨 🧹 ❌, ⏮️ 🇺🇸🔍 👔 📟 `418` & 🎻 🎚:
    
    ```JSON
    {"message": "Oops! yolo did something. There goes a rainbow..."}
    ```
    
    /// note | "📡 ℹ"
    
    👆 💪 ⚙️ `from starlette.requests import Request` & `from starlette.responses import JSONResponse`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.3K bytes
    - Viewed (0)
  9. docs/ru/docs/tutorial/handling-errors.md

    Но оно будет обработано `unicorn_exception_handler`.
    
    Таким образом, вы получите чистую ошибку с кодом состояния HTTP `418` и содержимым JSON:
    
    ```JSON
    {"message": "Oops! yolo did something. There goes a rainbow..."}
    ```
    
    /// note | "Технические детали"
    
    Также можно использовать `from starlette.requests import Request` и `from starlette.responses import JSONResponse`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 14.5K bytes
    - Viewed (0)
  10. docs/en/docs/tutorial/handling-errors.md

    But it will be handled by the `unicorn_exception_handler`.
    
    So, you will receive a clean error, with an HTTP status code of `418` and a JSON content of:
    
    ```JSON
    {"message": "Oops! yolo did something. There goes a rainbow..."}
    ```
    
    /// note | "Technical Details"
    
    You could also use `from starlette.requests import Request` and `from starlette.responses import JSONResponse`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 9.1K bytes
    - Viewed (0)
Back to top