Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 106 for 404 (0.14 sec)

  1. tests/test_generate_unique_id_function.py

        router = APIRouter()
    
        @app.post("/", response_model=List[Item], responses={404: {"model": List[Message]}})
        def post_root(item1: Item, item2: Item):
            return item1, item2  # pragma: nocover
    
        @router.post(
            "/router", response_model=List[Item], responses={404: {"model": List[Message]}}
        )
        def post_router(item1: Item, item2: Item):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Jan 13 15:10:26 GMT 2024
    - 66.7K bytes
    - Viewed (0)
  2. 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)
  3. 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)
  4. 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)
  5. docs/ru/docs/tutorial/handling-errors.md

    Они похожи на двухсотые HTTP статус-коды (от 200 до 299), которые означают, что запрос обработан успешно.
    
    Четырёхсотые статус-коды означают, что ошибка произошла по вине клиента.
    
    Помните ли ошибки **"404 Not Found "** (и шутки) ?
    
    ## Использование `HTTPException`
    
    Для возврата клиенту HTTP-ответов с ошибками используется `HTTPException`.
    
    ### Импортируйте `HTTPException`
    
    ```Python hl_lines="1"
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 14.5K 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. docs_src/dependencies/tutorial008b.py

    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: str = Depends(get_username)):
        if item_id not in data:
            raise HTTPException(status_code=404, detail="Item not found")
        item = data[item_id]
        if item["owner"] != username:
            raise OwnerError(username)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue Dec 26 20:37:34 GMT 2023
    - 735 bytes
    - Viewed (0)
  8. docs_src/dependencies/tutorial008b_an.py

    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
        if item_id not in data:
            raise HTTPException(status_code=404, detail="Item not found")
        item = data[item_id]
        if item["owner"] != username:
            raise OwnerError(username)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue Dec 26 20:37:34 GMT 2023
    - 785 bytes
    - Viewed (0)
  9. tests/test_route_scope.py

        response = client.post("/users/rick")
        assert response.status_code == 405, response.text
    
    
    def test_invalid_path_doesnt_match():
        response = client.post("/usersx/rick")
        assert response.status_code == 404, response.text
    
    
    def test_websocket():
        with client.websocket_connect("/items/portal-gun") as websocket:
            data = websocket.receive_json()
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Feb 08 10:23:07 GMT 2023
    - 1.5K bytes
    - Viewed (0)
  10. docs_src/sql_databases/sql_app_py39/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 Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1.6K bytes
    - Viewed (0)
Back to top