Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1091 - 1100 of 1,977 for Fastapi (0.09 sec)

  1. 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():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 231 bytes
    - Viewed (0)
  2. docs/zh/docs/tutorial/response-status-code.md

    `201` 表示**已创建**的状态码。
    
    但我们没有必要记住所有代码的含义。
    
    可以使用 `fastapi.status` 中的快捷变量。
    
    ```Python hl_lines="1  6"
    {!../../docs_src/response_status_code/tutorial002.py!}
    ```
    
    这只是一种快捷方式,具有相同的数字代码,但它可以使用编辑器的自动补全功能:
    
    <img src="../../../../../../img/tutorial/response-status-code/image02.png">
    
    /// note | "技术细节"
    
    也可以使用 `from starlette import status`。
    
    为了让开发者更方便,**FastAPI** 提供了与 `starlette.status` 完全相同的 `fastapi.status`。但它直接来自于 Starlette。
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.7K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_dependencies/test_tutorial008c.py

    import pytest
    from fastapi.exceptions import FastAPIError
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.dependencies.tutorial008c import app
    
        client = TestClient(app)
        return client
    
    
    def test_get_no_item(client: TestClient):
        response = client.get("/items/foo")
        assert response.status_code == 404, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Feb 24 23:06:37 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  4. docs/ja/docs/tutorial/security/index.md

    Google、Facebook、Twitter、GitHubなど、他の認証/認可プロバイダを統合することも可能で、比較的簡単です。
    
    最も複雑な問題は、それらのような認証/認可プロバイダを構築することですが、**FastAPI**は、あなたのために重い仕事をこなしながら、それを簡単に行うためのツールを提供します。
    
    ///
    
    ## **FastAPI** ユーティリティ
    
    FastAPIは `fastapi.security` モジュールの中で、これらのセキュリティスキームごとにいくつかのツールを提供し、これらのセキュリティメカニズムを簡単に使用できるようにします。
    
    次の章では、**FastAPI** が提供するこれらのツールを使って、あなたのAPIにセキュリティを追加する方法について見ていきます。
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Aug 06 04:48:30 UTC 2024
    - 6K bytes
    - Viewed (0)
  5. docs/zh/docs/deployment/server-workers.md

    /// info
    
    如果您正在使用容器,例如 Docker 或 Kubernetes,我将在下一章中告诉您更多相关信息:[容器中的 FastAPI - Docker](docker.md){.internal-link target=_blank}。
    
    特别是,当在 **Kubernetes** 上运行时,您可能**不想**使用 Gunicorn,而是运行 **每个容器一个 Uvicorn 进程**,但我将在本章后面告诉您这一点。
    
    ///
    
    ## Gunicorn with Uvicorn Workers
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Aug 06 04:48:30 UTC 2024
    - 8.7K bytes
    - Viewed (0)
  6. docs_src/security/tutorial004_py310.py

    from datetime import datetime, timedelta, timezone
    
    import jwt
    from fastapi import Depends, FastAPI, HTTPException, status
    from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
    from jwt.exceptions import InvalidTokenError
    from passlib.context import CryptContext
    from pydantic import BaseModel
    
    # to get a string like this run:
    # openssl rand -hex 32
    SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 4K bytes
    - Viewed (0)
  7. docs/pt/docs/advanced/middleware.md

    new_app = UnicornMiddleware(app, some_config="rainbow")
    ```
    
    Mas, o FastAPI (na verdade, o Starlette) fornece uma maneira mais simples de fazer isso que garante que os middlewares internos lidem com erros do servidor e que os manipuladores de exceções personalizados funcionem corretamente.
    
    Para isso, você usa `app.add_middleware()` (como no exemplo para CORS).
    
    ```Python
    from fastapi import FastAPI
    from unicorn import UnicornMiddleware
    
    app = FastAPI()
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 30 20:00:22 UTC 2024
    - 4.3K bytes
    - Viewed (0)
  8. docs_src/security/tutorial001_an.py

    from fastapi import Depends, FastAPI
    from fastapi.security import OAuth2PasswordBearer
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
    
    
    @app.get("/items/")
    async def read_items(token: Annotated[str, Depends(oauth2_scheme)]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 319 bytes
    - Viewed (0)
  9. docs_src/security/tutorial001_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI
    from fastapi.security import OAuth2PasswordBearer
    
    app = FastAPI()
    
    oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
    
    
    @app.get("/items/")
    async def read_items(token: Annotated[str, Depends(oauth2_scheme)]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 309 bytes
    - Viewed (0)
  10. docs/zh/docs/tutorial/dependencies/classes-as-dependencies.md

    
    fluffy = Cat(name="Mr Fluffy")
    ```
    
    在这个例子中, `fluffy` 是一个 `Cat` 类的实例。
    
    为了创建 `fluffy`,你调用了 `Cat` 。
    
    所以,Python 类也是 **可调用对象**。
    
    因此,在 **FastAPI** 中,你可以使用一个 Python 类作为一个依赖项。
    
    实际上 FastAPI 检查的是它是一个 "可调用对象"(函数,类或其他任何类型)以及定义的参数。
    
    如果您在 **FastAPI** 中传递一个 "可调用对象" 作为依赖项,它将分析该 "可调用对象" 的参数,并以处理路径操作函数的参数的方式来处理它们。包括子依赖项。
    
    这也适用于完全没有参数的可调用对象。这与不带参数的路径操作函数一样。
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.4K bytes
    - Viewed (0)
Back to top