Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 1,000 for returns (0.55 sec)

  1. docs/en/docs/advanced/testing-dependencies.md

    ### Use cases: external service
    
    An example could be that you have an external authentication provider that you need to call.
    
    You send it a token and it returns an authenticated user.
    
    This provider might be charging you per request, and calling it might take some extra time than if you had a fixed mock user for tests.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 2.9K bytes
    - Viewed (0)
  2. docs/en/docs/advanced/settings.md

    #### `lru_cache` Technical Details
    
    `@lru_cache` modifies the function it decorates to return the same value that was returned the first time, instead of computing it again, executing the code of the function every time.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 15.7K bytes
    - Viewed (0)
  3. tests/test_infer_param_optionality.py

    @user_router.get("/")
    def get_users():
        return [{"user_id": "u1"}, {"user_id": "u2"}]
    
    
    @user_router.get("/{user_id}")
    def get_user(user_id: str):
        return {"user_id": user_id}
    
    
    @item_router.get("/")
    def get_items(user_id: Optional[str] = None):
        if user_id is None:
            return [{"item_id": "i1", "user_id": "u1"}, {"item_id": "i2", "user_id": "u2"}]
        else:
            return [{"item_id": "i2", "user_id": user_id}]
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.3K bytes
    - Viewed (0)
  4. docs/en/docs/tutorial/path-params-numeric-validations.md

    !!! note "Technical Details"
        When you import `Query`, `Path` and others from `fastapi`, they are actually functions.
    
        That when called, return instances of classes of the same name.
    
        So, you import `Query`, which is a function. And when you call it, it returns an instance of a class also named `Query`.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  5. docs/en/docs/advanced/custom-response.md

    ```
    
    ### `HTMLResponse`
    
    Takes some text or bytes and returns an HTML response, as you read above.
    
    ### `PlainTextResponse`
    
    Takes some text or bytes and returns an plain text response.
    
    ```Python hl_lines="2  7  9"
    {!../../../docs_src/custom_response/tutorial005.py!}
    ```
    
    ### `JSONResponse`
    
    Takes some data and returns an `application/json` encoded response.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 11.7K bytes
    - Viewed (0)
  6. docs/en/docs/advanced/security/http-basic-auth.md

    That way, using `secrets.compare_digest()` in your application code, it will be safe against this whole range of security attacks.
    
    ### Return the error
    
    After detecting that the credentials are incorrect, return an `HTTPException` with a status code 401 (the same returned when no credentials are provided) and add the header `WWW-Authenticate` to make the browser show the login prompt again:
    
    === "Python 3.9+"
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jan 11 14:33:05 GMT 2024
    - 5.9K bytes
    - Viewed (0)
  7. fastapi/dependencies/utils.py

        if inspect.isroutine(call):
            return inspect.iscoroutinefunction(call)
        if inspect.isclass(call):
            return False
        dunder_call = getattr(call, "__call__", None)  # noqa: B004
        return inspect.iscoroutinefunction(dunder_call)
    
    
    def is_async_gen_callable(call: Callable[..., Any]) -> bool:
        if inspect.isasyncgenfunction(call):
            return True
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Apr 02 02:52:56 GMT 2024
    - 29.5K bytes
    - Viewed (0)
  8. docs/en/docs/advanced/additional-status-codes.md

    For example, let's say that you want to have a *path operation* that allows to update items, and returns HTTP status codes of 200 "OK" when successful.
    
    But you also want it to accept new items. And when the items didn't exist before, it creates them, and returns an HTTP status code of 201 "Created".
    
    To achieve that, import `JSONResponse`, and return your content there directly, setting the `status_code` that you want:
    
    === "Python 3.10+"
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 2.6K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/sql-databases.md

    Without `orm_mode`, if you returned a SQLAlchemy model from your *path operation*, it wouldn't include the relationship data.
    
    Even if you declared those relationships in your Pydantic models.
    
    But with ORM mode, as Pydantic itself will try to access the data it needs from attributes (instead of assuming a `dict`), you can declare the specific data you want to return and it will be able to go and get it, even from ORMs.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 29.6K bytes
    - Viewed (0)
  10. docs/en/docs/how-to/extending-openapi.md

    The normal (default) process, is as follows.
    
    A `FastAPI` application (instance) has an `.openapi()` method that is expected to return the OpenAPI schema.
    
    As part of the application object creation, a *path operation* for `/openapi.json` (or for whatever you set your `openapi_url`) is registered.
    
    It just returns a JSON response with the result of the application's `.openapi()` method.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Aug 19 19:54:04 GMT 2023
    - 3.2K bytes
    - Viewed (0)
Back to top