- Sort Score
- Result 10 results
- Languages All
Results 31 - 40 of 156 for 404 (0.15 sec)
-
tests/test_tutorial/test_dependencies/test_tutorial008d.py
client = TestClient(app) return client def test_get_no_item(client: TestClient): response = client.get("/items/foo") assert response.status_code == 404, response.text assert response.json() == {"detail": "Item not found, there's only a plumbus here"} def test_get(client: TestClient): response = client.get("/items/plumbus")
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Feb 24 23:06:37 GMT 2024 - 1.2K bytes - Viewed (0) -
docs/zh/docs/advanced/additional-responses.md
您可以向路径操作装饰器传递参数 `responses` 。 它接收一个 `dict`,键是每个响应的状态代码(如`200`),值是包含每个响应信息的其他 `dict`。 每个响应字典都可以有一个关键模型,其中包含一个 `Pydantic` 模型,就像 `response_model` 一样。 **FastAPI**将采用该模型,生成其`JSON Schema`并将其包含在`OpenAPI`中的正确位置。 例如,要声明另一个具有状态码 `404` 和`Pydantic`模型 `Message` 的响应,可以写: ```Python hl_lines="18 22" {!../../../docs_src/additional_responses/tutorial001.py!} ``` !!! Note 请记住,您必须直接返回 `JSONResponse` 。 !!! Info `model` 密钥不是OpenAPI的一部分。
Plain Text - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Tue Jan 09 15:53:39 GMT 2024 - 8.2K bytes - Viewed (0) -
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) -
tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py
client = TestClient(app) return client @needs_py39 def test_get_no_item(client: TestClient): response = client.get("/items/foo") assert response.status_code == 404, response.text assert response.json() == {"detail": "Item not found"} @needs_py39 def test_owner_error(client: TestClient): response = client.get("/items/plumbus")
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Feb 24 23:06:37 GMT 2024 - 918 bytes - Viewed (0) -
tests/test_tutorial/test_first_steps/test_tutorial001.py
client = TestClient(app) @pytest.mark.parametrize( "path,expected_status,expected_response", [ ("/", 200, {"message": "Hello World"}), ("/nonexistent", 404, {"detail": "Not Found"}), ], ) def test_get_path(path, expected_status, expected_response): response = client.get(path) assert response.status_code == expected_status
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Fri Jun 30 18:25:16 GMT 2023 - 1.2K bytes - Viewed (0) -
tests/test_tutorial/test_dependencies/test_tutorial008d_an.py
client = TestClient(app) return client def test_get_no_item(client: TestClient): response = client.get("/items/foo") assert response.status_code == 404, response.text assert response.json() == {"detail": "Item not found, there's only a plumbus here"} def test_get(client: TestClient): response = client.get("/items/plumbus")
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Feb 24 23:06:37 GMT 2024 - 1.2K bytes - Viewed (0) -
docs_src/app_testing/app_b_py310/main.py
if x_token != fake_secret_token: raise HTTPException(status_code=400, detail="Invalid X-Token header") if item_id not in fake_db: raise HTTPException(status_code=404, detail="Item not found") return fake_db[item_id] @app.post("/items/", response_model=Item) async def create_item(item: Item, x_token: str = Header()): if x_token != fake_secret_token:
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Tue Jan 09 14:44:08 GMT 2024 - 1.1K bytes - Viewed (0) -
docs/en/docs/tutorial/handling-errors.md
Plain Text - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Fri Mar 22 01:42:11 GMT 2024 - 9.1K bytes - Viewed (0) -
docs_src/app_testing/app_b_an/main.py
if x_token != fake_secret_token: raise HTTPException(status_code=400, detail="Invalid X-Token header") if item_id not in fake_db: raise HTTPException(status_code=404, detail="Item not found") return fake_db[item_id] @app.post("/items/", response_model=Item) async def create_item(item: Item, x_token: Annotated[str, Header()]): if x_token != fake_secret_token:
Python - Registered: Sun Apr 21 07:19:11 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 1.2K bytes - Viewed (0) -
docs/pt/docs/tutorial/handling-errors.md
Os status codes na faixa dos 400 significam que houve um erro por parte do cliente. Você se lembra de todos aqueles erros (e piadas) a respeito do "**404 Not Found**"? ## Use o `HTTPException` Para retornar ao cliente *responses* HTTP com erros, use o `HTTPException`. ### Import `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 - 10K bytes - Viewed (0)