Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 97 for 404 (0.15 sec)

  1. tests/test_tutorial/test_conditional_openapi/test_tutorial001.py

        client = get_client()
        response = client.get("/openapi.json")
        assert response.status_code == 404, response.text
        response = client.get("/docs")
        assert response.status_code == 404, response.text
        response = client.get("/redoc")
        assert response.status_code == 404, response.text
    
    
    @needs_pydanticv2
    def test_root():
        client = get_client()
        response = client.get("/")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.8K bytes
    - Viewed (0)
  2. docs_src/additional_responses/tutorial003.py

        id: str
        value: str
    
    
    class Message(BaseModel):
        message: str
    
    
    app = FastAPI()
    
    
    @app.get(
        "/items/{item_id}",
        response_model=Item,
        responses={
            404: {"model": Message, "description": "The item was not found"},
            200: {
                "description": "Item requested by ID",
                "content": {
                    "application/json": {
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 837 bytes
    - Viewed (0)
  3. docs_src/bigger_applications/app_an/routers/items.py

        responses={404: {"description": "Not found"}},
    )
    
    
    fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
    
    
    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1011 bytes
    - Viewed (0)
  4. docs_src/additional_responses/tutorial001.py

    class Message(BaseModel):
        message: str
    
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}", response_model=Item, responses={404: {"model": Message}})
    async def read_item(item_id: str):
        if item_id == "foo":
            return {"id": "foo", "value": "there goes my hero"}
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Aug 26 13:32:30 GMT 2022
    - 506 bytes
    - Viewed (0)
  5. tests/test_starlette_exception.py

    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: str):
        if item_id not in items:
            raise HTTPException(
                status_code=404,
                detail="Item not found",
                headers={"X-Error": "Some custom header"},
            )
        return {"item": items[item_id]}
    
    
    @app.get("/http-no-body-statuscode-exception")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 7.4K bytes
    - Viewed (0)
  6. docs_src/bigger_applications/app/routers/items.py

        responses={404: {"description": "Not found"}},
    )
    
    
    fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
    
    
    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sun Nov 29 17:32:18 GMT 2020
    - 1011 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_additional_responses/test_tutorial001.py

        assert response.json() == {"id": "foo", "value": "there goes my hero"}
    
    
    def test_path_operation_not_found():
        response = client.get("/items/bar")
        assert response.status_code == 404, response.text
        assert response.json() == {"message": "Item not found"}
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 4.3K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_additional_responses/test_tutorial003.py

        assert response.json() == {"id": "foo", "value": "there goes my hero"}
    
    
    def test_path_operation_not_found():
        response = client.get("/items/bar")
        assert response.status_code == 404, response.text
        assert response.json() == {"message": "Item not found"}
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 4.5K bytes
    - Viewed (0)
  9. docs_src/bigger_applications/app_an_py39/routers/items.py

        responses={404: {"description": "Not found"}},
    )
    
    
    fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
    
    
    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1011 bytes
    - Viewed (0)
  10. docs/de/docs/advanced/additional-responses.md

    **FastAPI** nimmt dieses Modell, generiert dessen JSON-Schema und fügt es an der richtigen Stelle in OpenAPI ein.
    
    Um beispielsweise eine weitere Response mit dem Statuscode `404` und einem Pydantic-Modell `Message` zu deklarieren, können Sie schreiben:
    
    ```Python hl_lines="18  22"
    {!../../../docs_src/additional_responses/tutorial001.py!}
    ```
    
    !!! note "Hinweis"
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:19:26 GMT 2024
    - 9.6K bytes
    - Viewed (0)
Back to top