Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 106 for 404 (0.53 sec)

  1. docs_src/sql_databases/sql_app_py39/alt_main.py

    @app.get("/users/{user_id}", response_model=schemas.User)
    def read_user(user_id: int, db: Session = Depends(get_db)):
        db_user = crud.get_user(db, user_id=user_id)
        if db_user is None:
            raise HTTPException(status_code=404, detail="User not found")
        return db_user
    
    
    @app.post("/users/{user_id}/items/", response_model=schemas.Item)
    def create_item_for_user(
        user_id: int, item: schemas.ItemCreate, db: Session = Depends(get_db)
    ):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1.9K bytes
    - Viewed (0)
  2. 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 May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:19:26 GMT 2024
    - 9.6K bytes
    - Viewed (0)
  3. docs/en/docs/advanced/additional-responses.md

    **FastAPI** will take that model, generate its JSON Schema and include it in the correct place in OpenAPI.
    
    For example, to declare another response with a status code `404` and a Pydantic model `Message`, you can write:
    
    ```Python hl_lines="18  22"
    {!../../../docs_src/additional_responses/tutorial001.py!}
    ```
    
    !!! note
        Keep in mind that you have to return the `JSONResponse` directly.
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 8.8K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_sql_databases/test_sql_databases.py

        assert "id" in data
    
    
    # TODO: pv2 add version with Pydantic v2
    @needs_pydanticv1
    def test_nonexistent_user(client):
        response = client.get("/users/999")
        assert response.status_code == 404, response.text
    
    
    # TODO: pv2 add version with Pydantic v2
    @needs_pydanticv1
    def test_get_users(client):
        response = client.get("/users/")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 16.1K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_sql_databases/test_sql_databases_middleware_py310.py

        assert "id" in data
    
    
    @needs_py310
    # TODO: pv2 add version with Pydantic v2
    @needs_pydanticv1
    def test_nonexistent_user(client):
        response = client.get("/users/999")
        assert response.status_code == 404, response.text
    
    
    @needs_py310
    # TODO: pv2 add version with Pydantic v2
    @needs_pydanticv1
    def test_get_users(client):
        response = client.get("/users/")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 16.5K bytes
    - Viewed (0)
  6. docs_src/handling_errors/tutorial001.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")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 299 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_handling_errors/test_tutorial001.py

        assert response.status_code == 200, response.text
        assert response.json() == {"item": "The Foo Wrestlers"}
    
    
    def test_get_item_not_found():
        response = client.get("/items/bar")
        assert response.status_code == 404, response.text
        assert response.headers.get("x-error") is None
        assert response.json() == {"detail": "Item not found"}
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  8. docs_src/sql_databases_peewee/sql_app/main.py

        "/users/{user_id}", response_model=schemas.User, dependencies=[Depends(get_db)]
    )
    def read_user(user_id: int):
        db_user = crud.get_user(user_id=user_id)
        if db_user is None:
            raise HTTPException(status_code=404, detail="User not found")
        return db_user
    
    
    @app.post(
        "/users/{user_id}/items/",
        response_model=schemas.Item,
        dependencies=[Depends(get_db)],
    )
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 2.2K bytes
    - Viewed (0)
  9. docs_src/dependencies/tutorial008c_an_py39.py

            raise InternalError(
                f"The portal gun is too dangerous to be owned by {username}"
            )
        if item_id != "plumbus":
            raise HTTPException(
                status_code=404, detail="Item not found, there's only a plumbus here"
            )
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 700 bytes
    - Viewed (0)
  10. docs_src/additional_responses/tutorial004.py

    from typing import Union
    
    from fastapi import FastAPI
    from fastapi.responses import FileResponse
    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        id: str
        value: str
    
    
    responses = {
        404: {"description": "Item not found"},
        302: {"description": "The item was moved"},
        403: {"description": "Not enough privileges"},
    }
    
    
    app = FastAPI()
    
    
    @app.get(
        "/items/{item_id}",
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 701 bytes
    - Viewed (0)
Back to top