Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 10 for add_middleware (0.2 sec)

  1. docs/de/docs/advanced/middleware.md

    Dazu verwenden Sie `app.add_middleware()` (wie schon im Beispiel für CORS gesehen).
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    app.add_middleware(UnicornMiddleware, some_config="rainbow")
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 20:18:15 GMT 2024
    - 4.4K bytes
    - Viewed (0)
  2. docs/em/docs/advanced/middleware.md

    ```
    
    ✋️ FastAPI (🤙 💃) 🚚 🙅 🌌 ⚫️ 👈 ⚒ 💭 👈 🔗 🛠️ 🍵 💽 ❌ & 🛃 ⚠ 🐕‍🦺 👷 ☑.
    
    👈, 👆 ⚙️ `app.add_middleware()` (🖼 ⚜).
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    app.add_middleware(UnicornMiddleware, some_config="rainbow")
    ```
    
    `app.add_middleware()` 📨 🛠️ 🎓 🥇 ❌ & 🙆 🌖 ❌ 🚶‍♀️ 🛠️.
    
    ## 🛠️ 🛠️
    
    **FastAPI** 🔌 📚 🛠️ ⚠ ⚙️ 💼, 👥 🔜 👀 ⏭ ❔ ⚙️ 👫.
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Apr 01 09:26:04 GMT 2023
    - 3.3K bytes
    - Viewed (0)
  3. docs/en/docs/advanced/middleware.md

    For that, you use `app.add_middleware()` (as in the example for CORS).
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    app.add_middleware(UnicornMiddleware, some_config="rainbow")
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 10 18:27:10 GMT 2023
    - 4K bytes
    - Viewed (0)
  4. docs/zh/docs/advanced/middleware.md

    ```
    
    但 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()` 的第一个参数是中间件的类,其它参数则是要传递给中间件的参数。
    
    ## 集成中间件
    
    **FastAPI** 为常见用例提供了一些中间件,下面介绍怎么使用这些中间件。
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 22:44:27 GMT 2024
    - 3.6K bytes
    - Viewed (0)
  5. docs_src/advanced_middleware/tutorial002.py

    from fastapi import FastAPI
    from fastapi.middleware.trustedhost import TrustedHostMiddleware
    
    app = FastAPI()
    
    app.add_middleware(
        TrustedHostMiddleware, allowed_hosts=["example.com", "*.example.com"]
    )
    
    
    @app.get("/")
    async def main():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 279 bytes
    - Viewed (0)
  6. docs_src/advanced_middleware/tutorial003.py

    from fastapi import FastAPI
    from fastapi.middleware.gzip import GZipMiddleware
    
    app = FastAPI()
    
    app.add_middleware(GZipMiddleware, minimum_size=1000)
    
    
    @app.get("/")
    async def main():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 213 bytes
    - Viewed (0)
  7. docs_src/advanced_middleware/tutorial001.py

    from fastapi import FastAPI
    from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware
    
    app = FastAPI()
    
    app.add_middleware(HTTPSRedirectMiddleware)
    
    
    @app.get("/")
    async def main():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 231 bytes
    - Viewed (0)
  8. docs_src/cors/tutorial001.py

    app = FastAPI()
    
    origins = [
        "http://localhost.tiangolo.com",
        "https://localhost.tiangolo.com",
        "http://localhost",
        "http://localhost:8080",
    ]
    
    app.add_middleware(
        CORSMiddleware,
        allow_origins=origins,
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )
    
    
    @app.get("/")
    async def main():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 459 bytes
    - Viewed (0)
  9. tests/test_custom_middleware_exception.py

    
    @router.post("/middleware")
    def run_middleware(file: UploadFile = File(..., description="Big File")):
        return {"message": "OK"}
    
    
    app.include_router(router)
    app.add_middleware(ContentSizeLimitMiddleware, max_content_size=2**8)
    
    
    client = TestClient(app)
    
    
    def test_custom_middleware_exception(tmp_path: Path):
        default_pydantic_max_size = 2**16
        path = tmp_path / "test.txt"
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Aug 25 21:44:40 GMT 2022
    - 2.8K bytes
    - Viewed (0)
  10. fastapi/applications.py

                Doc(
                    """
                    List of middleware to be added when creating the application.
    
                    In FastAPI you would normally do this with `app.add_middleware()`
                    instead.
    
                    Read more in the
                    [FastAPI docs for Middleware](https://fastapi.tiangolo.com/tutorial/middleware/).
                    """
                ),
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
Back to top