Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for CustomORJSONResponse (0.24 sec)

  1. docs_src/custom_response/tutorial009c.py

    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():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Sep 01 09:32:30 UTC 2022
    - 451 bytes
    - Viewed (0)
  2. docs/em/docs/advanced/custom-response.md

    ➡ī¸ đŸ’Ŧ 👆 💚 âšĢī¸ 📨 🔂 & 📁 đŸŽģ, 👆 💚 ⚙ī¸ Orjson 🎛 `orjson.OPT_INDENT_2`.
    
    👆 đŸ’Ē ✍ `CustomORJSONResponse`. 👑 👜 👆 ✔ī¸ ✍ `Response.render(content)` 👩‍đŸ”Ŧ 👈 📨 🎚 `bytes`:
    
    ```Python hl_lines="9-14  17"
    {!../../docs_src/custom_response/tutorial009c.py!}
    ```
    
    🔜 ↩ī¸ đŸ›Ŧ:
    
    ```json
    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