Search Options

Results per page
Sort
Preferred Languages
Advance

Results 221 - 230 of 1,675 for Responses (0.04 sec)

  1. fastapi/applications.py

            ] = None,
            default_response_class: Annotated[
                type[Response],
                Doc(
                    """
                    The default response class to be used.
    
                    Read more in the
                    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#default-response-class).
    
                    **Example**
    
                    ```python
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 176.3K bytes
    - Viewed (0)
  2. docs_src/additional_status_codes/tutorial001_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Body, FastAPI, status
    from fastapi.responses import JSONResponse
    
    app = FastAPI()
    
    items = {"foo": {"name": "Fighters", "size": 6}, "bar": {"name": "Tenders", "size": 3}}
    
    
    @app.put("/items/{item_id}")
    async def upsert_item(
        item_id: str,
        name: Annotated[Union[str, None], Body()] = None,
        size: Annotated[Union[int, None], Body()] = None,
    ):
        if item_id in items:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 705 bytes
    - Viewed (0)
  3. tests/test_security_oauth2_optional.py

    
    def test_security_oauth2_password_bearer_no_header():
        response = client.get("/users/me")
        assert response.status_code == 200, response.text
        assert response.json() == {"msg": "Create an account first"}
    
    
    def test_strict_login_no_data():
        response = client.post("/login")
        assert response.status_code == 422
        assert response.json() == {
            "detail": [
                {
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 8.9K bytes
    - Viewed (0)
  4. docs_src/bigger_applications/app_an_py39/main.py

    
    app.include_router(users.router)
    app.include_router(items.router)
    app.include_router(
        admin.router,
        prefix="/admin",
        tags=["admin"],
        dependencies=[Depends(get_token_header)],
        responses={418: {"description": "I'm a teapot"}},
    )
    
    
    @app.get("/")
    async def root():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 552 bytes
    - Viewed (0)
  5. tests/test_union_body.py

    client = TestClient(app)
    
    
    def test_post_other_item():
        response = client.post("/items/", json={"price": 100})
        assert response.status_code == 200, response.text
        assert response.json() == {"item": {"price": 100}}
    
    
    def test_post_item():
        response = client.post("/items/", json={"name": "Foo"})
        assert response.status_code == 200, response.text
        assert response.json() == {"item": {"name": "Foo"}}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 4.3K bytes
    - Viewed (0)
  6. tests/test_security_api_key_cookie.py

        client = TestClient(app, cookies={"key": "secret"})
        response = client.get("/users/me")
        assert response.status_code == 200, response.text
        assert response.json() == {"username": "secret"}
    
    
    def test_security_api_key_no_key():
        client = TestClient(app)
        response = client.get("/users/me")
        assert response.status_code == 401, response.text
        assert response.json() == {"detail": "Not authenticated"}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 24 19:03:06 UTC 2025
    - 2K bytes
    - Viewed (0)
  7. docs/es/docs/tutorial/bigger-applications.md

    ### Agregar algunos `tags`, `responses`, y `dependencies` personalizados { #add-some-custom-tags-responses-and-dependencies }
    
    No estamos agregando el prefijo `/items` ni los `tags=["items"]` a cada *path operation* porque los hemos añadido al `APIRouter`.
    
    Pero aún podemos agregar _más_ `tags` que se aplicarán a una *path operation* específica, y también algunas `responses` extra específicas para esa *path operation*:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Dec 16 16:33:45 UTC 2025
    - 19.6K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_header_params/test_tutorial003.py

    def test(path, headers, expected_status, expected_response, client: TestClient):
        response = client.get(path, headers=headers)
        assert response.status_code == expected_status
        assert response.json() == expected_response
    
    
    def test_openapi_schema(client: TestClient):
        response = client.get("/openapi.json")
        assert response.status_code == 200
        assert response.json() == {
            "openapi": "3.1.0",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 4.1K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_debugging/test_tutorial001.py

            importlib.import_module(MOD_NAME)
        uvicorn_run_mock.assert_not_called()
    
    
    def test_get_root(client: TestClient):
        response = client.get("/")
        assert response.status_code == 200
        assert response.json() == {"hello world": "ba"}
    
    
    def test_uvicorn_run_called_when_run_as_main():  # Just for coverage
        if sys.modules.get(MOD_NAME):
            del sys.modules[MOD_NAME]
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 1.8K bytes
    - Viewed (0)
  10. docs_src/handling_errors/tutorial005_py39.py

    from fastapi import FastAPI, Request
    from fastapi.encoders import jsonable_encoder
    from fastapi.exceptions import RequestValidationError
    from fastapi.responses import JSONResponse
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    @app.exception_handler(RequestValidationError)
    async def validation_exception_handler(request: Request, exc: RequestValidationError):
        return JSONResponse(
            status_code=422,
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 626 bytes
    - Viewed (0)
Back to top