Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 46 for media (0.21 sec)

  1. tests/test_request_body_parameters_media_type.py

    app = FastAPI()
    
    media_type = "application/vnd.api+json"
    
    
    # NOTE: These are not valid JSON:API resources
    # but they are fine for testing requestBody with custom media_type
    class Product(BaseModel):
        name: str
        price: float
    
    
    class Shop(BaseModel):
        name: str
    
    
    @app.post("/products")
    async def create_product(data: Product = Body(media_type=media_type, embed=True)):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 6.4K bytes
    - Viewed (0)
  2. docs/en/docs/reference/responses.md

                - status_code
                - media_type
                - body
                - background
                - raw_headers
                - render
                - init_headers
                - headers
                - set_cookie
                - delete_cookie
    
    ::: fastapi.responses.ORJSONResponse
        options:
            members:
                - charset
                - status_code
                - media_type
                - body
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 3.7K bytes
    - Viewed (0)
  3. docs/en/docs/advanced/custom-response.md

    * `content` - A `str` or `bytes`.
    * `status_code` - An `int` HTTP status code.
    * `headers` - A `dict` of strings.
    * `media_type` - A `str` giving the media type. E.g. `"text/html"`.
    
    FastAPI (actually Starlette) will automatically include a Content-Length header. It will also include a Content-Type header, based on the media_type and appending a charset for text types.
    
    ```Python hl_lines="1  18"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 11.7K bytes
    - Viewed (0)
  4. docs_src/custom_response/tutorial009c.py

    from typing import Any
    
    import orjson
    from fastapi import FastAPI, Response
    
    app = FastAPI()
    
    
    class CustomORJSONResponse(Response):
        media_type = "application/json"
    
        def render(self, content: Any) -> bytes:
            assert orjson is not None, "orjson must be installed"
            return orjson.dumps(content, option=orjson.OPT_INDENT_2)
    
    
    @app.get("/", response_class=CustomORJSONResponse)
    async def main():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Sep 01 09:32:30 GMT 2022
    - 451 bytes
    - Viewed (0)
  5. docs_src/custom_response/tutorial008.py

    
    @app.get("/")
    def main():
        def iterfile():  # (1)
            with open(some_file_path, mode="rb") as file_like:  # (2)
                yield from file_like  # (3)
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Jul 19 19:14:58 GMT 2021
    - 360 bytes
    - Viewed (0)
  6. docs_src/additional_responses/tutorial002.py

                "description": "Return the JSON item or an image.",
            }
        },
    )
    async def read_item(item_id: str, img: Union[bool, None] = None):
        if img:
            return FileResponse("image.png", media_type="image/png")
        else:
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 628 bytes
    - Viewed (0)
  7. docs_src/response_directly/tutorial002.py

        <shampoo>
        <Header>
            Apply shampoo here.
        </Header>
        <Body>
            You'll have to use soap here.
        </Body>
        </shampoo>
        """
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 354 bytes
    - Viewed (0)
  8. docs/de/docs/tutorial/request-forms.md

    **FastAPI** stellt sicher, dass diese Daten korrekt ausgelesen werden, statt JSON zu erwarten.
    
    !!! note "Technische Details"
        Daten aus Formularen werden normalerweise mit dem <abbr title='Media type – Medientyp, Typ des Mediums'>„media type“</abbr> `application/x-www-form-urlencoded` kodiert.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 18:06:54 GMT 2024
    - 3.7K bytes
    - Viewed (0)
  9. fastapi/params.py

            include_in_schema: bool = True,
            json_schema_extra: Union[Dict[str, Any], None] = None,
            **extra: Any,
        ):
            self.embed = embed
            self.media_type = media_type
            if example is not _Unset:
                warnings.warn(
                    "`example` has been deprecated, please use `examples` instead",
                    category=DeprecationWarning,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 27.5K bytes
    - Viewed (1)
  10. docs/de/docs/advanced/custom-response.md

    * `status_code` – Ein `int`-HTTP-Statuscode.
    * `headers` – Ein `dict` von Strings.
    * `media_type` – Ein `str`, der den Medientyp angibt. Z. B. `"text/html"`.
    
    FastAPI (eigentlich Starlette) fügt automatisch einen Content-Length-Header ein. Außerdem wird es einen Content-Type-Header einfügen, der auf dem media_type basiert, und für Texttypen einen Zeichensatz (charset) anfügen.
    
    ```Python hl_lines="1  18"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 23 13:05:12 GMT 2024
    - 13.5K bytes
    - Viewed (0)
Back to top