Search Options

Results per page
Sort
Preferred Languages
Advance

Results 541 - 550 of 1,127 for def2 (0.02 sec)

  1. docs_src/separate_openapi_schemas/tutorial001.py

    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
    
    
    app = FastAPI()
    
    
    @app.post("/items/")
    def create_item(item: Item):
        return item
    
    
    @app.get("/items/")
    def read_items() -> List[Item]:
        return [
            Item(
                name="Portal Gun",
                description="Device to travel through the multi-rick-verse",
            ),
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 25 19:10:22 UTC 2023
    - 489 bytes
    - Viewed (0)
  2. docs/en/docs/tutorial/dependencies/index.md

    You can use `async def` or normal `def`.
    
    And you can declare dependencies with `async def` inside of normal `def` *path operation functions*, or `def` dependencies inside of `async def` *path operation functions*, etc.
    
    It doesn't matter. **FastAPI** will know what to do.
    
    /// note
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon Oct 28 11:18:17 UTC 2024
    - 9.2K bytes
    - Viewed (0)
  3. docs_src/request_files/tutorial001_02_an_py310.py

    from fastapi import FastAPI, File, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: Annotated[bytes | None, File()] = None):
        if not file:
            return {"message": "No file sent"}
        else:
            return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(file: UploadFile | None = None):
        if not file:
            return {"message": "No upload file sent"}
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 505 bytes
    - Viewed (0)
  4. docs_src/response_model/tutorial001_01.py

        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: List[str] = []
    
    
    @app.post("/items/")
    async def create_item(item: Item) -> Item:
        return item
    
    
    @app.get("/items/")
    async def read_items() -> List[Item]:
        return [
            Item(name="Portal Gun", price=42.0),
            Item(name="Plumbus", price=32.0),
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Jan 07 13:45:48 UTC 2023
    - 513 bytes
    - Viewed (0)
  5. docs/pt/docs/advanced/events.md

    Você pode definir manipuladores de eventos (funções) que precisam ser executadas antes da aplicação inicializar, ou quando a aplicação estiver encerrando.
    
    Essas funções podem ser declaradas com `async def` ou `def` normal.
    
    ### Evento `startup`
    
    Para adicionar uma função que deve rodar antes da aplicação iniciar, declare-a com o evento `"startup"`:
    
    ```Python hl_lines="8"
    {!../../docs_src/events/tutorial001.py!}
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.6K bytes
    - Viewed (0)
  6. docs/en/docs/advanced/events.md

    You can define event handlers (functions) that need to be executed before the application starts up, or when the application is shutting down.
    
    These functions can be declared with `async def` or normal `def`.
    
    ### `startup` event
    
    To add a function that should be run before the application starts, declare it with the event `"startup"`:
    
    {* ../../docs_src/events/tutorial001.py hl[8] *}
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon Oct 28 10:36:22 UTC 2024
    - 7.6K bytes
    - Viewed (0)
  7. docs_src/openapi_webhooks/tutorial001.py

        start_date: datetime
    
    
    @app.webhooks.post("new-subscription")
    def new_subscription(body: Subscription):
        """
        When a new user subscribes to your service we'll send you a POST request with this
        data to the URL that you register for the event `new-subscription` in the dashboard.
        """
    
    
    @app.get("/users/")
    def read_users():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Oct 20 09:00:44 UTC 2023
    - 550 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_schema_extra_example/test_tutorial005_an_py39.py

    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    
    from ...utils import needs_py39
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.schema_extra_example.tutorial005_an_py39 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py39
    def test_post_body_example(client: TestClient):
        response = client.put(
            "/items/5",
            json={
                "name": "Foo",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Aug 26 18:03:13 UTC 2023
    - 6.8K bytes
    - Viewed (0)
  9. .github/actions/notify-translations/app/main.py

        return comment_nodes
    
    
    def create_comment(*, settings: Settings, discussion_id: str, body: str):
        data = get_graphql_response(
            settings=settings,
            query=add_comment_mutation,
            discussion_id=discussion_id,
            body=body,
        )
        response = AddCommentResponse.parse_obj(data)
        return response.data.addDiscussionComment.comment
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon Jul 29 23:35:07 UTC 2024
    - 12.4K bytes
    - Viewed (0)
  10. docs/ja/docs/tutorial/dependencies/index.md

    `Depends`を渡すだけで、**FastAPI** が残りの処理をしてくれます。
    
    ///
    
    ## `async`にするかどうか
    
    依存関係は **FastAPI**(*path operation関数*と同じ)からも呼び出されるため、関数を定義する際にも同じルールが適用されます。
    
    `async def`や通常の`def`を使用することができます。
    
    また、通常の`def`*path operation関数*の中に`async def`を入れて依存関係を宣言したり、`async def`*path operation関数*の中に`def`を入れて依存関係を宣言したりすることなどができます。
    
    それは重要ではありません。**FastAPI** は何をすべきかを知っています。
    
    /// note | "備考"
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 9.7K bytes
    - Viewed (0)
Back to top